3 Replies - 649 Views - Last Post: 13 February 2014 - 03:50 PM Rate Topic: -----

#1 tools  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 68
  • Joined: 26-September 12

RoR: path will not load by url argument

Posted 13 February 2014 - 08:54 AM

Hey I am have a form with the "header"
<%= form_for :work, url: works_index_path  do |f| %>

Which do not work, though it yields this result: http://127.0.0.1:3000/works/index
I get this error:
No route matches [POST] "/works/index"

The routes output:
index_about_path	 GET	 /index/about(.:format)	 index#about
index_work_path	 GET	 /index/work(.:format)	 index#work
index_projects_path	 GET	 /index/projects(.:format)	 index#projects
index_education_path	 GET	 /index/education(.:format)	 index#education
index_blog_path	 GET	 /index/blog(.:format)	 index#blog
index_contact_path	 GET	 /index/contact(.:format)	 index#contact
works_index_path	 GET	 /works/index(.:format)	 works#index
works_new_path	 GET	 /works/new(.:format)	 works#new
root_path	 GET	 /	 index#about



and if I type in the url or just go to the addressbar and hits enter the page loads just find.

EDIT: the routes became messy in code so picture:

Posted Image

Can anyone tell me what the f... is wrong??? I still pretty green at rails

This post has been edited by tools: 13 February 2014 - 08:56 AM


Is This A Good Question/Topic? 0
  • +

Replies To: RoR: path will not load by url argument

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2085
  • View blog
  • Posts: 3,170
  • Joined: 21-June 11

Re: RoR: path will not load by url argument

Posted 13 February 2014 - 12:45 PM

Forms use post by default, but your index action is get. You could make your form use get using html: {method: "GET"}, which would make the form's contents show up in the URL. You could also change index to be post, but that would mean you can't get to it without a form.

Really it just seems very weird to me that you'd want to send stuff to index through a form. The best solution here might be to rethink that decision (but then I don't know what lead you to that decision in the first place, so I don't really know).
Was This Post Helpful? 2
  • +
  • -

#3 tools  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 68
  • Joined: 26-September 12

Re: RoR: path will not load by url argument

Posted 13 February 2014 - 03:28 PM

#2 sepp2k thank you I will take a look on it actually I think I chaging it to the create method
Was This Post Helpful? 0
  • +
  • -

#4 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1357
  • View blog
  • Posts: 3,424
  • Joined: 28-November 09

Re: RoR: path will not load by url argument

Posted 13 February 2014 - 03:50 PM

Do note that any changes to your routes and you'll need to restart your server.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1