Sending a variable through a link_to without url query in Ruby on Rails?

No need for a special method to get the info you need, the magic of routes will do.

No need for a special method to get the info you need, the magic of routes will do. In your routes. Db file, you should be able to define something like this, map.

Resources :class, :has_many => :students Then if you run 'rake routes' you should see a routes similar to this class_students GET /classes/:class_id/students(.:format) {:controller=>"students", :action=>"index"} You can call that path in your view like so class_students_path(class_id) Then in your controller you will have access to params:class_id The name of the route isn't very pretty, but this should work. EDIT-------------------------------------- According to your comment, you can't use map. Resources for some reason or another... map.

Class_students '/:class_id/students', :controller => 'students', :action => 'index' That will produce the same route available in your view, same param in your controller. That being said, I don't know how a server bug could prohibit you from using map.resources.

Due to a server bug that we still can't fix and due to the other developer wanting to go old school (no resources...). – Muralha Jan 14 '10 at 1:18 1 You don't have resources? Are you running an ancient version of Rails or something?

What kind of a server bug would affect that? – Ethan Gunderson Jan 14 '10 at 1:21 To fix the bug, the admin has to fix it manually (ruby 1.9/rails 2.3.4 bug... stackoverflow.Com/questions/1681685/…) and it's kinda of a sensitive server, so not luck until we finish the job and move it to another server. The other developer wants everything like rails 1.8.X... (old school... no luck too) Can I still use the resources without messing the rest?

And by the way, thanks for the help Ethan. – Muralha Jan 14 '10 at 1:42 Just to help DB Users id, ..., schoold_id Class_elements id, user_id, class_id (users can belong to 1 or more classes... teachers) Classes id, ..., school_id *Models* Users belongs_to :class_elements? Or has_many :class_elements?

Class_elements belongs_to :class belongs_to :users? Or has_many :users? Classes belongs_to :school has_many :class_elements – Muralha Jan 14 '10 at 1:45 Even on Rails 1.8. X you should be able to do Map.

Resources, according to apidock. Com it was introduced in 1.2 apidock. Com/rails/ActionController/Resources/resources.

I guess what I'm trying to say, if you have a Rails application up and running, using either one of those routing options shouldn't break anything on the server. – Ethan Gunderson Jan 14 '10 at 1:49.

You can not transfer data through a link without including that data in the link. However, it sounds like you just need to be using nested resources. (Since I speak English, I'm going to not tackle another language and do what comes to me.) The URLs you want to be sending people to probably should look more like this if you want to be RESTful: /classes/1/people/ That is the "Rails way" of indicating that you want to get people in class #1, and Rails offers built-in routing methods to make this easy.

See the Rails Routing from the Outside In article in the Rails Guide.

I think one problem we got with nested resources, was that one of our method was not working for not being a standard name method (editar == edit , or show == ver) and all the others were working... – Muralha Jan 14 '10 at 2:33.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions