Search Results

Search found 17357 results on 695 pages for 'custom attributes'.

Page 3/695 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • [VB.Net] System.IO will copy files, but fails to update destinations file attributes

    - by CFP
    Hello, I have a little vb.net script that will copy a file, set its attributes to Normal, update the file time, and then set back the attributes to match those of the source file. If IO.File.Exists(Destination) Then IO.File.SetAttributes(Destination, IO.FileAttributes.Normal) IO.File.Copy(Source, Destination, True) IO.File.SetAttributes(Destination, IO.FileAttributes.Normal) IO.File.SetLastWriteTimeUtc(Destination, IO.File.GetLastWriteTimeUtc(Destination).AddHours(1)) IO.File.SetAttributes(Destination, IO.File.GetAttributes(Source)) I however I'm encountering a quite strange problem. On some configurations, IO.File.SetLastWriteTimeUtc triggers an UnauthorizedAccess error, although the IO.File.Copy instruction worked very well. I'm totally puzzled: I've checked, and file attributes are set to 128 (ie. Normal) successfully. The problem seems to be with the very SetLastWriteTimeUtc. But what is it? Any ideas? Thanks a lot!

    Read the article

  • Django models & Python class attributes

    - by Geo
    The tutorial on the django website shows this code for the models: from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() Now, each of those attribute, is a class attribute, right? So, the same attribute should be shared by all instances of the class. A bit later, they present this code: class Poll(models.Model): # ... def __unicode__(self): return self.question class Choice(models.Model): # ... def __unicode__(self): return self.choice How did they turn from class attributes into instance attributes? Did I get class attributes wrong?

    Read the article

  • What is the best way to add attributes to auto-generated entities (using VS2010 and EF4)

    - by Dani
    ASP.NET MVC2 has strong support for using attributes on entities (validation, and extending Html helper class and more). If I generated my Model from the Database using VS2010 EF4 Entity Data Model (edmx and it's cs class), And I want to add attributes on some of the entities. what would be the best practice ? how should I cope with updating the model (adding more fields / tables to the database and merging them into the edmx) - will it keep my attributes or generate a new cs file erasing everything ? (Manual changes to this file may cause unexpected behavior in your application.) (Manual changes to this file will be overwritten if the code is regenerated.)

    Read the article

  • Developing a custom-validation in asp.net for specific control and criteria

    - by Gaurav
    Hello There is another relevant question asked Validation Check in asp.net In the same scenario we need a custom validator control which will alert user for any wrong entry. This will work like this : Developer will pass the control-name, input-value and format-required For instance like for textbox it can be: txtName,txtName.Text, allow-alphabets-only The accordingly format if the user input is invalid he/she will be got prompt. Please suggest the right way to do the smae. Thanks in advance.

    Read the article

  • C#/.NET: Retrieving the contents/file attributes from a file inside a recycle bin

    - by eibhrum
    Hi, I just wanna ask if there's a possibility to retrieve the contents of a 'dump' file from the recycle bin programatically. The contents that I'm looking for are file attributes like 'Date Last Modified, 'Data created', 'size', etc (without restoring the file itself to the original location to preserve the original attributes found while inside the recycle bin.) Comments and suggestions are highly appreciated. Thanks.

    Read the article

  • Attributes don't inherit?

    - by Stebi
    I played with attributes and assumed that they are inherited but it doesn't seem so: type [MyAttribute] TClass1 = class end; TClass2 = class(TClass1) end; TClass2 doesn't have the Attribute "MyAttribute" although it inherits from Class1. Is there any possibility to make an attribute inheritable? Or do I have to go up the class hierarchy and search for attributes?

    Read the article

  • Mocking attributes - C#

    - by bob
    I use custom Attributes in a project and I would like to integrate them in my unit-tests. Now I use Rhino Mocks to create my mocks but I don't see a way to add my attributes (and there parameters) to them. Did I miss something, or is it not possible? Other mocking framework? Or do I have to create dummy implementations with my attributes? example: I have an interface in a plugin-architecture (IPlugin) and there is an attribute to add meta info to a property. Then I look for properties with this attribute in the plugin implementation for extra processing (storing its value, mark as gui read-only...) Now when I create a mock can I add easily an attribute to a property or the object instance itself? EDIT: I found a post with the same question - link. The answer there is not 100% and it is Java... EDIT 2: It can be done... searched some more (on SO) and found 2 related questions (+ answers) here and here Now, is this already implemented in one or another mocking framework?

    Read the article

  • Making my own custom Ubuntu

    - by Benny
    I was wondering, is it possible to make my own customized version of Linux based on Ubuntu 10.10 ? I am thinking of calling it something different but I was wondering besides making a custom Live CD I am talking about an Linux that people can install on there computers using Ubuntu installation method. I want to base it on something other than GNOME but be able to install it latter on. Thanks in advance, Benny

    Read the article

  • Difference between OEM install and custom Ubuntu image

    - by Suman
    I'm looking into the best way to deploy a customized Ubuntu image and it looks like I have two options: To make an "OEM install" version To make a custom Ubuntu image Could someone help me understand the difference between these two methods of customizing a Ubuntu install? It appears to me that both these methods allow for elaborate customization of the image while allowing the user to enter their own end-user details (time zone, username, password, etc.)

    Read the article

  • Magento loadByAttribute for Custom Category Attributes

    - by Chris
    I have created custom attributes for a category in my module's install script like so: $attrib = array( 'type' => 'varchar', 'group' => 'My Data', 'backend' => '', 'frontend' => '', 'label' => 'My Custom Field', 'input' => 'text', 'class' => '', 'source' => '', 'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE, 'visible' => true, 'required' => false, 'user_defined' => false, 'default' => '', 'searchable' => false, 'filterable' => false, 'comparable' => false, 'visible_on_front' => false, 'unique' => true, ); $installer->addAttribute(3, 'custom_field', $attrib); The field shows up fine in the admin, and when I create the category in my script like so: $p_category = Mage::getModel('catalog/category') ->setStoreId(0) ->load(2); $category = Mage::getModel('catalog/category'); $category->setStoreId(0) ->setName('Test Category') ->setCustomField('abcd') ->setDisplayMode('PRODUCTS') ->setAttributeSetId($category->getDefaultAttributeSetId()) ->setIsActive(1) ->setIsAnchor(1) ->setPath(implode('/',$p_category->getPathIds())) ->setInitialSetupFlag(true) ->save(); I can see the value 'abcd' in the Magneto admin interface. But when I call the code below: <?php $category = Mage::getModel('catalog/category')->loadByAttribute('custom_field', 'abcd'); print_r($category); ?> I get no result. But if I loadByAttribute using the 'name' field set to 'Test Category', I DO get a result. So, in the database, I looked into the catalog_category_entity_varchar table and noticed that the 'name' attribute had an entry for both store_id = 0 AND store_id = 1 whereas the 'custom_field' attribute had only an entry for store_id = 1. When I added a store_id = 0 entry for 'custom_field' with the value set to 'abcd' in the catalog_category_entity_varchar table, loadByAttribute got the expected result. My question is, why is the 'name' field getting a store_id = 0 entry in catalog_category_entity_varchar and my custom field is not? How do I load categories by custom attributes?

    Read the article

  • Custom JComponent not displaying in Custom JPanel

    - by Trizicus
    I've tried the add() method but nothing is displayed when I try to add Test to GraphicsTest. How should I be adding it? Can someone show me? I've included the code I'm using. import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import javax.swing.JComponent; public class Test extends JComponent { Test() { setOpaque(false); setBackground(Color.white); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2d = (Graphics2D) g.create(); g2d.setColor(Color.red); g2d.drawString("Hello", 50, 50); g2d.dispose(); } } import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.geom.Rectangle2D; import javax.swing.JPanel; public class GraphicsTest extends JPanel implements MouseListener { private Graphics2D g2d; private String state; private int x, y; GraphicsTest() { add(new Test()); } @Override public void paintComponent(Graphics g) { super.paintComponent(g); g2d = (Graphics2D) g; g2d.setColor(Color.BLACK); g2d.drawString("STATE: " + state, 5, 15); g2d.drawString("Mouse Position: " + x + ", " + y, 5, 30); g2d.setColor(Color.red); Rectangle2D r2d = new Rectangle2D.Double(x, y, 10, 10); g2d.draw(r2d); g2d.dispose(); } public void setState(String state) { this.state = state; } public String getState() { return state; } public void setX(int x) { this.x = x; repaint(); } public void setY(int y) { this.y = y; repaint(); } public void mouseClicked(MouseEvent e) {} public void mousePressed(MouseEvent e) {} public void mouseReleased(MouseEvent e) {} public void mouseEntered(MouseEvent e) {} public void mouseExited(MouseEvent e) {} }

    Read the article

  • how to save nested form attributes to database

    - by siulamvictor
    I am not really understand how's the nested attributes work in Rails. I have 2 models, Accounts and Users. Accounts has_many Users. When a new user filled in the form, Rails reported User(#2164802740) expected, got Array(#2148376200) Is that Rails cannot read the nested attributes from the form? How can I fix it? How can I save the data from nested attributes form to database? Thanks all~ Here are the MVCs: Account Model class Account < ActiveRecord::Base has_many :users accepts_nested_attributes_for :users validates_presence_of :company_name, :message => "companyname is required." validates_presence_of :company_website, :message => "website is required." end User Model class User < ActiveRecord::Base belongs_to :account validates_presence_of :user_name, :message => "username too short." validates_presence_of :password, :message => "password too short." end Account Controller class AccountController < ApplicationController def new end def created end def create @account = Account.new(params[:account]) if @account.save redirect_to :action => "created" else flash[:notice] = "error!!!" render :action => "new" end end end Account/new View <h1>Account#new</h1> <% form_for :account, :url => { :action => "create" } do |f| %> <% f.fields_for :users do |ff| %> <p> <%= ff.label :user_name %><br /> <%= ff.text_field :user_name %> </p> <p> <%= ff.label :password %><br /> <%= ff.password_field :password %> </p> <% end %> <p> <%= f.label :company_name %><br /> <%= f.text_field :company_name %> </p> <p> <%= f.label :company_website %><br /> <%= f.text_field :company_website %> </p> <% end %> Account Migration class CreateAccounts < ActiveRecord::Migration def self.up create_table :accounts do |t| t.string :company_name t.string :company_website t.timestamps end end def self.down drop_table :accounts end end User Migration class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :user_name t.string :password t.integer :account_id t.timestamps end end def self.down drop_table :users end end Thanks everyone. :)

    Read the article

  • RegEx to extract all HTML tag attributes including inline JavaScript

    - by Mike
    I found this useful regex code here while looking to parse HTML tag attributes: (\S+)=["']?((?:.(?!["']?\s+(?:\S+)=|[>"']))+.)["']? It works great, but it's missing one key element that I need. Some attributes are event triggers that have inline Javascript code in them like this: onclick="doSomething(this, 'foo', 'bar');return false;" Or: onclick='doSomething(this, "foo", "bar");return false;' I can't figure out how to get the original expression to not count the quotes from the JS (single or double) while it's nested inside the set of quotes that contain the attribute's value.

    Read the article

  • Inheritance of Custom Attributes on Abstract Properties

    - by Marty Trenouth
    I've got a custom attribute that I want to apply to my base abstract class so that I can skip elements that don't need to be viewed by the user when displaying the item in HTML. It seems that the properties overriding the base class are not inheriting the attributes. Does overriding base properties (abstract or virtual) blow away attributes placed on the original property? From Attribute class Defination [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = false)] public class NoHtmlOutput : Attribute { } From Abstract Class Defination [NoHtmlOutput] public abstract Guid UniqueID { get; set; } From Concrete Class Defination public override Guid UniqueID{ get{ return MasterId;} set{MasterId = value;}} From class checking for attribute Type t = o.GetType(); foreach (PropertyInfo pi in t.GetProperties()) { if (pi.GetCustomAttributes(typeof(NoHtmlOutput), true).Length == 1) continue; // processing logic goes here }

    Read the article

  • Ruby on Rails - nested attributes: How do I access the parent model from child model

    - by TMaYaD
    I have a couple of models like so class Bill < ActiveRecord::Base has_many :bill_items belongs_to :store accepts_nested_attributes_for :bill_items end class BillItem <ActiveRecord::Base belongs_to :product belongs_to :bill validate :has_enough_stock def has_enough_stock stock_available = Inventory.product_is(self.product).store_is(self.bill.store).one.quantity errors.add(:quantity, "only #{stock_available} is available") if stock_available < self.quantity end end The above validation so obviously doesn't work because when I'm reading the bill_items from nested attributes inside the bill form, the attributes bill_item.bill_id or bill_item.bill are not available before being saved. So how do I go about doing something like that?

    Read the article

  • rails nested attributes

    - by user342798
    I am using rails 3.0.0.beta3 and I am trying to implement form with nested attributes using :accepts_nested_attributes_for. My form is nested to three levels: Survey Question Answer. Survey has_many Questions, and Question has many Answers. Inside the Survey model, there is :accepts_nested_attributes_for :questions and inside the question mode, there is :accepts_nested_attributes_for :answers Everything is working fine except when I add a new answer to an existing question, it doesn't get created. However, if I make changes to the corresponding question while creating the answer, I can successfully create the answer. This example is exactly similar to a railscast: http://railscasts.com/episodes/197-nested-model-form-part-2 but doesn't work in rails3 (at least in my case). Please let me know if there is any issue with nested attributes in Rails 3. Thanks in advance.

    Read the article

  • .Net SvcUtil: attributes must be optional

    - by Michel van Engelen
    Hi, I'm trying to generate C# code classes with SvcUtil.exe instead of Xsd.exe. The latter is giving me some problems. Command line: SvcUtil.exe myschema.xsd /dconly /ser:XmlSerializer Several SvcUtil problems are described and solved here: http://blog.shutupandcode.net/?p=761 One problem I can't solve is this one: Error: Type 'DatafieldDescription' in namespace '' cannot be imported. Attributes must be optional and from namespace 'http://schemas.microsoft.com/2003/10/Seri alization/'. Either change the schema so that the types can map to data contract types or use ImportXmlType or use a different serializer. ' I changed <xs:attribute name="Order" use="required"> to <xs:attribute name="Order" use="optional"> and <xs:attribute name="Order"> But the error remains. Is it possible to use attributes, or do I have to delete them all (in that case, this excercition is over)?

    Read the article

  • Can I add custom methods/attributes to built-in Python types?

    - by sfjedi
    For example—say I want to add a helloWorld() method to Python's dict type. Can I do this? JavaScript has a prototype object that behaves this way. Maybe it's bad design and I should subclass the dict object, but then it only works on the subclasses and I want it to work on any and all future dictionaries. Here's how it would go down in JavaScript: String.prototype.hello = function() { alert("Hello, " + this + "!"); } "Jed".hello() //alerts "Hello, Jed!" Here's a useful link with more examples— http://www.javascriptkit.com/javatutors/proto3.shtml

    Read the article

  • Server-side Javascript (aspx.cs) Attributes.Add Code to Change a Label's text

    - by DFM
    I am trying to change a label's text by using server-side javascript (onclick) and C# within the page_load event. For example, I would like to write something like the following: Label1.Attributes.Add("onclick", "Label2.text='new caption'") Does anyone know the correct code for this? Also, what is this type of code referred to; is it just javascript or javascript in C# or is there a specific name? Lastly, does a book or online resource exist that lists the choices of control.attributes.add("event", "syntax") code to use with C#? Thank you, DFM

    Read the article

  • How to clone a model's attributes easily?

    - by Zabba
    I have these models: class Address < ActiveRecord::Base belongs_to :event attr_accessible :street, :city validates :street, :city, :presence => true end class Event < ActiveRecord::Base has_one :address accepts_nested_attributes_for :address end If I do the below assignment in the Events create action and save the event I get an error: #Use the current user's address for the event @event.address_attributes = current_user.address.attributes #Error occurs at the above mentioned line ActiveRecord::RecordNotFound (Couldn't find Address with ID=1 for Event with ID=) I think what's happening is that all the address's attributes (including the primary key) is getting assigned in the @event.address_attributes = line. But all I really want is the "real data" (street, city), not the primary keys or created_at etc to get copied over. I suppose I could write a small method to do this sort of selective copy but I can't help but feel there must be some built-in method for this? What's the best/right way to do this?

    Read the article

  • google custom search gives different result number for same query

    - by santiagozky
    We are using google custom search and we have found that often the totalResults iterates between two values, even for the same query. The different values can be slightly different or more than double. The parameters I am using look like this: https://www.googleapis.com/customsearch/v1? q=something cx=XXXXXXXXXX lr=lang_en siteSearch=www.mydomain.com start=1 fields=context%2Citems%28fileFormat%2CformattedUrl%2Clink%2Cpagemap%2Csnippet%2Ctitle%29%2Cqueries%2CsearchInformation%28searchTime%2CtotalResults%29%2Cspelling%2FcorrectedQuery key=YYYYYYYYYYYYYYY filter=0 This is problem because of calculating the number of result pages. How can I get the same results for the same query?

    Read the article

  • Storage model for various user setting and attributes in database?

    - by dvd
    I'm currently trying to upgrade a user management system for one web application. This web application is used to provide remote access to various networking equipment for educational purposes. All equipment is assigned to various pods, which users can book for periods of time. The current system is very simple - just 2 user types: administrators and students. All their security and other attributes are mostly hardcoded. I want to change this to something like the following model: user <-- (1..n)profile <--- (1..n) attributes. I.e. user can be assigned several profiles and each profile can have multiple attributes. At runtime all profiles and attributes are merged into single active profile. Some examples of attributes i'm planning to implement: EXPIRATION_DATE - single value, value type: date, specifies when user account will expire; ACCESS_POD - single value, value type: ref to object of Pod class, specifies which pod the user is allowed to book, user profile can have multiple such attributes with different values; TIME_QUOTA - single value, value type: integer, specifies maximum length of time for which student can reserve equipment. CREDIT_CHARGING - multi valued, specifies how much credits will be assigned to user over period of time. (Reservation of devices will cost credits, which will regenerate over time); Security permissions and user preferences can end up as profile or user attributes too: i.e CAN_CREATE_USERS, CAN_POST_NEWS, CAN_EDIT_DEVICES, FONT_SIZE, etc.. This way i could have, for example: students of course A will have profiles STUDENT (with basic attributes) and PROFILE A (wich grants acces to pod A). Students of course B will have profiles: STUDENT, PROFILE B(wich grants to pod B and have increased time quotas). I'm using Spring and Hibernate frameworks for this application and MySQL for database. For this web application i would like to stay within boundaries of these tools. The problem is, that i can't figure out how to best represent all these attributes in database. I also want to create some kind of unified way of retrieveing these attributes and their values. Here is the model i've come up with. Base classes. public abstract class Attribute{ private Long id; Attribute() {} abstract public String getName(); public Long getId() {return id; } void setId(Long id) {this.id = id;} } public abstract class SimpleAttribute extends Attribute{ public abstract Serializable getValue(); abstract void setValue(Serializable s); @Override public boolean equals(Object obj) { ... } @Override public int hashCode() { ... } } Simple attributes can have only one value of any type (including object and enum). Here are more specific attributes: public abstract class IntAttribute extends SimpleAttribute { private Integer value; public Integer getValue() { return value; } void setValue(Integer value) { this.value = value;} void setValue(Serializable s) { setValue((Integer)s); } } public class MaxOrdersAttribute extends IntAttribute { public String getName() { return "Maximum outstanding orders"; } } public final class CreditRateAttribute extends IntAttribute { public String getName() { return "Credit Regeneration Rate"; } } All attributes stored stored using Hibenate variant "table per class hierarchy". Mapping: <class name="ru.mirea.rea.model.abac.Attribute" table="ATTRIBUTES" abstract="true" > <id name="id" column="id"> <generator class="increment" /> </id> <discriminator column="attributeType" type="string"/> <subclass name="ru.mirea.rea.model.abac.SimpleAttribute" abstract="true"> <subclass name="ru.mirea.rea.model.abac.IntAttribute" abstract="true" > <property name="value" column="intVal" type="integer"/> <subclass name="ru.mirea.rea.model.abac.CreditRateAttribute" discriminator-value="CreditRate" /> <subclass name="ru.mirea.rea.model.abac.MaxOrdersAttribute" discriminator-value="MaxOrders" /> </subclass> <subclass name="ru.mirea.rea.model.abac.DateAttribute" abstract="true" > <property name="value" column="dateVal" type="timestamp"/> <subclass name="ru.mirea.rea.model.abac.ExpirationDateAttribute" discriminator-value="ExpirationDate" /> </subclass> <subclass name="ru.mirea.rea.model.abac.PodAttribute" abstract="true" > <many-to-one name="value" column="podVal" class="ru.mirea.rea.model.pods.Pod"/> <subclass name="ru.mirea.rea.model.abac.PodAccessAttribute" discriminator-value="PodAccess" lazy="false"/> </subclass> <subclass name="ru.mirea.rea.model.abac.SecurityPermissionAttribute" discriminator-value="SecurityPermission" lazy="false"> <property name="value" column="spVal" type="ru.mirea.rea.db.hibernate.customTypes.SecurityPermissionType"/> </subclass> </subclass> </class> SecurityPermissionAttribute uses enumeration of various permissions as it's value. Several types of attributes imlement GrantedAuthority interface and can be used with Spring Security for authentication and authorization. Attributes can be created like this: public final class AttributeManager { public <T extends SimpleAttribute> T createSimpleAttribute(Class<T> c, Serializable value) { Session session = HibernateUtil.getCurrentSession(); T att = null; ... att = c.newInstance(); att.setValue(value); session.save(att); session.flush(); ... return att; } public <T extends SimpleAttribute> List<T> findSimpleAttributes(Class<T> c) { List<T> result = new ArrayList<T>(); Session session = HibernateUtil.getCurrentSession(); List<T> temp = session.createCriteria(c).list(); result.addAll(temp); return result; } } And retrieved through User Profiles to which they are assigned. I do not expect that there would be very large amount of rows in the ATTRIBUTES table, but are there any serious drawbacks of such design?

    Read the article

  • Can't mass-assign protected attributes -- unsolved issue

    - by nfriend21
    I have read about 10 different posts here about this problem, and I have tried every single one and the error will not go away. So here goes: I am trying to have a nested form on my users/new page, where it accepts user-attributes and also company-attributes. When you submit the form: Here's what my error message reads: ActiveModel::MassAssignmentSecurity::Error in UsersController#create Can't mass-assign protected attributes: companies app/controllers/users_controller.rb:12:in `create' Here's the code for my form: <%= form_for @user do |f| %> <%= render 'shared/error_messages', object: f.object %> <%= f.fields_for :companies do |c| %> <%= c.label :name, "Company Name"%> <%= c.text_field :name %> <% end %> <%= f.label :name %> <%= f.text_field :name %> <%= f.label :email %> <%= f.text_field :email %> <%= f.label :password %> <%= f.password_field :password %> <%= f.label :password_confirmation %> <%= f.password_field :password_confirmation %> <br> <% if current_page?(signup_path) %> <%= f.submit "Sign Up", class: "btn btn-large btn-primary" %> Or, <%= link_to "Login", login_path %> <% else %> <%= f.submit "Update User", class: "btn btn-large btn-primary" %> <% end %> <% end %> Users Controller: class UsersController < ApplicationController def index @user = User.all end def new @user = User.new end def create @user = User.create(params[:user]) if @user.save session[:user_id] = @user.id #once user account has been created, a session is not automatically created. This fixes that by setting their session id. This could be put into Controller action to clean up duplication. flash[:success] = "Your account has been created!" redirect_to tasks_path else render 'new' end end def show @user = User.find(params[:id]) @tasks = @user.tasks end def edit @user = User.find(params[:id]) end def update @user = User.find(params[:id]) if @user.update_attributes(params[:user]) flash[:success] = @user.name.possessive + " profile has been updated" redirect_to @user else render 'edit' end #if @task.update_attributes params[:task] #redirect_to users_path #flash[:success] = "User was successfully updated." #end end def destroy @user = User.find(params[:id]) unless current_user == @user @user.destroy flash[:success] = "The User has been deleted." end redirect_to users_path flash[:error] = "Error. You can't delete yourself!" end end Company Controller class CompaniesController < ApplicationController def index @companies = Company.all end def new @company = Company.new end def edit @company = Company.find(params[:id]) end def create @company = Company.create(params[:company]) #if @company.save #session[:user_id] = @user.id #once user account has been created, a session is not automatically created. This fixes that by setting their session id. This could be put into Controller action to clean up duplication. #flash[:success] = "Your account has been created!" #redirect_to tasks_path #else #render 'new' #end end def show @comnpany = Company.find(params[:id]) end end User model class User < ActiveRecord::Base has_secure_password attr_accessible :name, :email, :password, :password_confirmation has_many :tasks, dependent: :destroy belongs_to :company accepts_nested_attributes_for :company validates :name, presence: true, length: { maximum: 50 } VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } validates :password, length: { minimum: 6 } #below not needed anymore, due to has_secure_password #validates :password_confirmation, presence: true end Company Model class Company < ActiveRecord::Base attr_accessible :name has_and_belongs_to_many :users end Thanks for your help!!

    Read the article

  • Custom Attributes in Android

    - by Arun
    I'm trying to create a custom attribute called Tag for all editable elements. I added the following to attrs.xml <declare-styleable name="Spinner"> <attr name="tag" format="string" /> </declare-styleable> <declare-styleable name="EditText"> <attr name="tag" format="string" /> </declare-styleable> I get an error saying "Attribute tag has already been defined" for the EditText. Is it not possible to create a custom attribute of the same name on different elements?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >