Ruby on Rails Tuesday, June 26, 2012

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)

> 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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment