similar to: Diff between attr_accessible and attr_accessor

Displaying 20 results from an estimated 2000 matches similar to: "Diff between attr_accessible and attr_accessor"

2011 Mar 07
3
difference between attr_accessor and attr_accessible?
Hi, What''s the difference between attr_accessor and attr_accessible? Is attr_accessor to create a virtual variable/object and attr_accessible makes it accessible? Do you need attr_accessible if you already have attr_accessor? Thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails:
2009 Nov 27
2
attr_accessible & attr_accessor - what's the difference?
i''m still new to rails and working on digesting everything i come across. recently i came across these two. what is the difference between attr_accessor and attr_accessible? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2007 Jan 24
2
attr_accessor vs attr_accessible
Please guide me how to use those two methods. I can''t differentiate them. I was doing something on my model and I have put one field in the attr_accessible method. After that when I try to run the app the app always says my other fields are blank, but they''re all filled up. What''s wrong with it? Thanks --~--~---------~--~----~------------~-------~--~----~ You received
2006 Feb 05
3
attr_accessor help understanding
i''m having trouble understanding the attr_accessor and attr_accessible syntax in models. I''m workink through the Agile book and even a look at the ruby doc does not really help to clarify. Thanks aftershock -- Posted via http://www.ruby-forum.com/.
2011 May 20
3
How to handle non model data in form?
Hey, I got a form which looks like this: - form_for(@article, :html => {:multipart => true}, :url => articles_path) do |f| = errors_for(@article) .field = f.label :text %br = f.text_field :text .field = f.label :author_id %br = f.text_field :author_id .actions = f.submit But since I don''t want anyone to type in an author id I changed it
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give to the controller: User.create :name
2006 Feb 15
8
Agile book - getting confusing error
Working through the beginning phase from the Agile book on ''Administration'' undefined method `hashed_password='' for #<User:0xb7911324> ... /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing'' #{RAILS_ROOT}/app/models/user.rb:12:in `before_create''
2006 Jan 12
9
Scaffold shows all attributes altough I use attr_accessible!
Hi all I have a Model like this: class Member < ActiveRecord::Base attr_accessible :username, :email, :first_name, :last_name end I have created a scaffold using script/generate scaffold member members Using the URL localhost:3000/members/edit/1 I can edit all attributes, including created_at, lock_version etc.! But it should only show the attributes I listed in attr_accessible! What
2006 Apr 03
7
Getters and setters problem?
Hi list, first evening of playing with rails, so please forgive me if I ask something stupid. ;-) I created a User model and tried to use ActiveRecord callbacks to convert the password to sha1 just before saving it. For some reason postgresql gives me a error because the given password is null. To test even further I tried to change :login too, same error happens, :login is empty too. I am sure
2005 Oct 25
3
How to get the source code for login generator
Hi, I installed login generator using gem. It''s installed and it''s working fine. I wanted to browse the source code of login generator installed by gem. I couldn''t find the source code anywhere. Thanks. -=- Neeraj _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
2010 Nov 02
7
Testing attr_accessible (and/or attr_protected)
I''ve been puzzling over how to test that attr_accessible has been set for the correct columns; but the tests I''ve come up with so far seem to fail to fail when I expect. I came across this old message from this list: http://www.mail-archive.com/rspec-users at rubyforge.org/msg01570.html Which seemed like a plausible example, but my attempt (modeled on the example)
2012 Jul 09
10
attr_accessible on some properties + attr_protected on others makes class 'open-by-default'
(I posted this as a bug in GitHub (https://github.com/rails/rails/issues/7018), but then someone there told me I should post it here, so here it is.) If you set attr_accessible on some properties in an ActiveRecord-descended class, and then attr_protected on others - the class becomes ''default-open'' - if any properties are missed or added later, they will be accessible by
2006 Mar 04
4
Two quick newbie questions
2 quick questions regarding authentication ... 1) the flash[:notice] on successful login looks completely wrong to me. How should it be done? def index if request.post? @user = User.new(params[:user]) authentic_user = @user.attempt_login if authentic_user session[:user_id] = authentic_user.id flash[:notice] = ''Login successful! Welcome
2010 Nov 28
2
Dynamic find_by method returning nil in a class method
I have a user Model with a class method that I am using to do some authentication basically something like this class User < ActiveRecord::Base attr_accessor :password attr_accessible :first_name, :last_name, :email, :birth_date, :sex, :password, :password_confirmation email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :first_name,
2007 Oct 16
12
Example for attr_accessible?
Is anyone out there writing specs to check attr_accessible fields? I had originally written my spec to check for allowing the desired fields, and then none of the other regular db fields. Unfortunately this isn''t satisfactory, because attr_protected could have been used instead, which of course wouldn''t prevent mass assignment to any whatever=(val) method. I''m thinking
2005 Dec 17
1
lost in an ActiveRecord::StatementInvalid
I have an error I don''t know how to debug. I am adding the login suport in Depot (the example in the RoR book) and LoginController#add_user throws ActiveRecord::StatementInvalid in an innocent /login/add_user GET request. The trace goes down to a call to SQLiteAdapter#table_structure, and the source code suggests what''s happening is that "PRAGMA
2006 Jan 14
3
How to render from a different controller
My code is something like this. class FirstController < ApplicationController def foo #some processing render (:controller => ''second'', :action => ''index'') end end I tried using both render and redirect but it seems it''s not possible to send the control from within a controller to some other controller. Am I missing something
2011 Feb 03
5
Ignore attr_accessible in seed file
Is there a way to tell Rails to ignore attr_accessible when seeding the database and to allow mass assignment with create or new? I know how to skip validations but do not find anything on mass assignment... -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to
2006 Jan 11
6
How to display the error messages from the controller
I have a wizard which consists of two pages. To keep it simple let''s say that the first page asks the user to select a state from the drop down menu. In case the user doesn''t select any state, an error message needs to be displayed. Ideally I would like to do something like this. def new selected_value = params[:addevent][:state_id] if selected_value == "-1"
2012 Apr 27
1
Can't mass-assign protected attributes even if I use attr_accessible
Hi, I''m working on a Rails 3.2.2 application which has JSON APIs and I use a CLI client for inserting some data. It works fine except for the Author model. When I try to create a new post (Post belongs_to :author and Author has_many :posts) I get the following error : <h1> ActiveModel::MassAssignmentSecurity::Error in PostsController#create </h1>