On 17 August 2012 11:07, network DB <[email protected]> wrote:
> Colin Law wrote in post #1072628:
>> On 17 August 2012 01:30, network DB <[email protected]> wrote:
>>> I've got User has_one Shop. Rails is not validating when I tried
>>> create_shop or build_shop, neither in the browser nor the rails console.
>>
>> Those methods create the object but do not save it (see section
>> 4.1.1.3 in the Rails Guide on Associations).  Validation happens when
>> the record is saved (or valid? is called).
>>
>> Colin
>
> Yeah but in the browser, it just went straight to the show action
> without showing any validation warning at all. If it fails validation,
> it should render the shops#new action again.

Well you have a bug in your code then.  Have a look in development.log
to see what happens when you click the link.  Then have a look at the
Rails Guide on Debugging to get further ideas on how to debug the
code.

>
> Here's the error message it gives me when I click submit in the
> shops#new form without inputting anything and then it tried to go to the
> show action:
>
> Routing Error
>
> No route matches {:action=>"show", :controller=>"shops", :id=>#<Shop id:
> nil, user_id: 1, name: "", primary_address: "", secondary_address: "",
> city: "", postal_code: "", state_code: nil, country_code: "", phone: "",
> email: "", website: "", facebook: "", twitter: "", opening_hours: "",
> description: "", latitude: nil, longitude: nil, logo: nil, currency:
> "AED", created_at: nil, updated_at: nil>}
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to