On Jun 26, 2012, at 5:00 PM, cyber c. wrote: > Hi Walter, > > Thanks for your comments. > >> >> def create -> same for def submit too >> >> respond_to do |format| >> if PARAM matches so and so >> DEPENDING on params this gets routed to different page > > at any point here do you instantiate a new instance of your model, > assign the params to it, and try to save it? Until you try to save, your > validations won't fire. > >>> I didn't instantiate a new instance of my model. When i try to instantiate > @record = Record.new(params[:record]) > fires an error "wrong number of arguments ( 1 for 0) " > I have removed the default new definition, as i thought i dont need > it(im not storing the info in a DB, but processing the form data)
What version of Rails? I see a Railscast here from 2010 that has that very same code, and no error. But it also has an initialize method hand-written into the model: def initialize(attributes = {}) attributes.each do |name, value| send("#{name}=", value) end end You might need something like that to "persist" the data long enough for your controller to do something with it. http://railscasts.com/episodes/219-active-model Walter > >> else >> format.html { redirect_to records_url} >> format.json { head :no_content } >> end >> end >> >> end >> >> Should i write my controller differently to handle the errors? > > You might want to look at a vanilla scaffold controller and see how it's > done canonically before you reinvent the wheel. There are separate > create and update methods for a reason. > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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 rubyonrails-talk@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- 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 rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.