jacr1614
jacr1614

Reputation: 1310

rails execute the view without execute the controller's action

I have a controller and an action in there, but rails just show the view without execute the action. I'm creating something like a contact_us, so I have in my routes

  get '/contact-us'     => 'desktop#contact_us'
  post '/contact_send'  => 'desktop#contact'

So, in contact-us, it show me the form, when I send the form rails show the contact_send view, but without execute the controller's action, nothing in there runs.

in my controller

  def contact_us

  end

  def contact_send
    contact_us = Contact.new user_params
    contact_us.save

    redirect_to '/contact-us', notice: 'Contact message was send successfully.'

  end

And in the form view it is just a form that is sending to /contact, and in taht view I just have text like "this is mi test view " to know it the view is showing", and the text is showing, but the controller action doesn't runs, even when i write and error on purpose

Upvotes: 0

Views: 77

Answers (1)

sugaryourcoffee
sugaryourcoffee

Reputation: 879

Your contact_send is pointing to desktop#contact action. But your controller doesn't show a contact action. So your contact_send action isn't called.

Change

post '/contact_send' => 'desktop#contact'

to

post '/contact_send' => 'desktop#contact_send'

and check if this works.

Upvotes: 1

Related Questions