See below for my controller and view code. Are MySQL's database files encrypted? How to set phaser to kill the mermaids? You might be better off validating the user input before you turn it into a date object. check over here
So an instance of News is called news and therefore your instance variable would be @news rather than @news_form. Can't figure out why @customer is being assigned to value nil. "You have a nil object when you didn't expect it! You may have to register before you can post: click the register link above to proceed. So defining a variable in one action doesn't make it available in another action. (i'm wondering if you thought that they were shared, hence your error). http://stackoverflow.com/questions/6243600/update-attributes-nomethoderror-when-form-value-contains-question-mark-in-rails
You might have expected an instance of ActiveRecord::Base. Are 3.1 gems incompatible with ruby 1.8.7? –Cookies Jun 5 '11 at 16:03 @Zameer. When the browser then requests the next page, Rails creates another instance of the Controller class and calls the method that matches the new request. SitePoint Sponsor User Tag List Results 1 to 7 of 7 Thread: Unexpected nil object Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode
If you are to get the most out of Rails, you need to understand the conventions - even if (as I suggested above) you find yourself breaking them from time to You might have expected an instance of ActiveRecord::Base. Thanks. Not the answer you're looking for?
First off you are calling @user = User.find(params[:user_id]) every time in your controller. Either this is a user who has not been created in the DB yet, or your User.find call is not working to return an actual user. Originally Posted by dan06 I ended up changing the controller (and the views accordingly) to the following. If you're using update_attributes, and you have fields which are allowed to be blank, the user will never be able to clear those fields if you remove them from the params
The best way of thinking about this I think, is that when your browser requests a page, Rails creates an instance of the Controller class, then calls the method name that On Dec 15, 2007 9:12 AM, John Edward
But if you don't want that, you can convert empty values to nils with active record callbacks. check this link right here now Originally Posted by ReggieB And standard Rails convention is to use a simpler name for an instance of a class. You might have expected an instance of Array. Disproving Euler proposition by brute force in C Are MySQL's database files encrypted?
To start viewing messages, select the forum that you want to visit from the selection below. check my blog Therefore the new instance has to be able to create its instance variables on its own. Aug 12, 2009,10:23 #5 dan06 View Profile View Forum Posts SitePoint Enthusiast Join Date May 2009 Posts 47 Mentioned 0 Post(s) Tagged 0 Thread(s) Originally Posted by ReggieB Items are not Browse other questions tagged ruby-on-rails activerecord update-attributes or ask your own question.
You can find out more information about the move and how to open a new account (if necessary) here. There are often good reasons to break the conventions, but that should always be a concious decision. You can specify a param you want returned from the method like my set_user example. this content John Edward (texinsj) on 2007-12-15 09:39 I have a pre-populated Factor row that belongs to a Job (Job has one Factor).
Usually like this - (assuming that you want to make a new one rather than update)@news_form = NewsForm.new(params[:news_form])if @news_form.save ..etcbtw, you should look into restful routes - your actions do the update_attribute @DarkMouse, validating the format of the date object isn't as necessary once you've turned it into a DateTime object. Terms Privacy Security Status Help You can't perform that action at this time.
John Edward (texinsj) on 2007-12-15 18:12 Frederick Cheung wrote: > > What is params[:job_id]. How could a language that uses a single word extremely often sustain itself? And you're absolutely right, it is a bit annoying to learn these conventions - but even at this early stage I can see the benefits of using rails (and the conventions). And standard Rails convention is to use a simpler name for an instance of a class.
Derogatory term for a nobleman How could a language that uses a single word extremely often sustain itself? asked 5 years ago viewed 422 times active 5 years ago Related 723Why is null an object and what's the difference between null and undefined?708A concise explanation of nil v. If you see any other rails convention inconsistencies, let me know. have a peek at these guys Report post Edit Delete Reply with quote Re: nil.update_attributes on variable from find_by...
You might have expected an instance of ActiveRecord::Base. Should work as it will return a Date object that can then be saved into your database u.update_attribute(:birthday, DateTime.strptime("12/22/1992", "%m/%d/%Y") update_attribute (sans 's') takes the parameters (name, value). Python 学习笔记 - socketserver.. 通过Docker进程pid获取容器id 那些年我们学Flask-login，踩过史.. 友情链接 IT精品课程 51cto博客开发 小于的blog 7 p Free Ruby and Rai.. 每天一剂Rails良药.. How to Get That Triangulated Low-Poly Look?
Git学习教程（二）：配置.. The error occurred while evaluating nil.reverse Sorry, the ArgumentError I mentioned was irrelevant. You might have expected an instance of ActiveRecord::Base.