Rails 3 Named Routes - Calling different actions in the controller dynamically as a parameter with the same named route


HOME ยป Web Design

Say i have a controller with index and doesn't have any other RESTful actions. I want to call different actions as a parametr from the same controller which has a named route as follows.


Example,


I have TargetsController and i should be able to call


targets_path(any_action, params)

Can i call


resources :targets do
get :action_name, :on => :member
end

on a controller that does not have the Restful actions


How do i write this in the routes.rb ? All the documentation i found did not talk about how the same r


Related to : Rails 3 Named Routes - Calling different actions in the controller dynamically as a parameter with the same named route
link_to project index possible with customized routes.rb and without a Named route in Rails?
Web Design

my routes.rb looks like this


map.resources :bookmarks
map.connect ':controller/:id/:action'
map.connect ':controller/:action'

so i can use urls like this


http://localhost:3000/bookmarks/Ruby/show

but when i try to link from this site to the index site of the project (bookmarks
controller and index action) like this


link_to "Startseite", :controller => "bookmarks"

it links to


http://localhost:3000/bookmarks/Ruby/

instead of


http://loc
Rails 3 Named Routes - Calling different actions in the controller dynamically as a parameter with the same named route
Web Design

Say i have a controller with index and doesn't have any other RESTful actions. I want to call different actions as a parametr from the same controller which has a named route as follows.


Example,


I have TargetsController and i should be able to call


targets_path(any_action, params)

Can i call


resources :targets do
get :action_name, :on => :member
end

on a controller that does not have the Restful actions


How do i write this in the routes.rb ? All the documentation i found did not talk about how the same r

rails named routes + controller as parameter
Web Design

is it possible to have the controller value in a rails named route as a parameter, which I can pass at runtime to direct the call to the proper controller?


e.g.
map.ride 'ride' ,:controller => {some-way-of-specifying-a-parameter}, :action => 'ride'


then at runtime, I want to pass the controller name to which this call should be going. My actions are doing different things depending to which controller the call gets sent.
thanks


rails routes confusing show action with named route
Web Design

i have a problem implementing a list action with its own route. here is what i have
(just important parts)
routes.rb


map.resources :posts
map.login "login" ,:controller => "user_sessions" ,:action => "new"
map.logout "logout" , :controller => "user_sessions" , :action => "destroy"
map.sort "sort" , :controller => "posts" , :action => "sort"

posts_controller.rb


class PostsController < ApplicationController
def index
logger.info "index params:::"+params.inspect
@posts = current_user.posts.paginate :page => params[
about rails' routes, adding collection routes to restful resources won't generate named route helpers?
Web Design

namespace :admin do
resources :posts do
collection do
get 'whatever'
end
end
end

I was expect that will generate 'whatever_admin_posts_path' helper method, but it didn't.
It's there something wrong with my codes? Or a bug in rails?


Calling a controller's action without a named route in Rails 3
Web Design

In Rails 3, is there a way to link to a controller's action using ajax without having a named route?


I tried <%= link_to 'Reload', '#', url_for(:action => :reload, :id => @user.id), :remote => true, :method => 'post' %>


but it returns with the error No route matches {:controller=>"users", :id=>2, :action=>"reload"}


My main concern is that I don't want the action to be called by someone typing in a route in the address bar. Is there another way to go about this?


Thanks!


Tim



HD Wallpapers
3D
3D Abstract
City
Celebrities
Indian Celebrities
Cars
Travel
Girls
Animals Birds
Movies
Sports
Black White
Nature
Planes
Anime
Food Drink
Dreamy Fantasy
Architecture
Games
Space
Holidays
Flowers
Love
Artistic
Baby
Beach
Bikes Motorcycles
Macro
Computers
Vector
Funny
Army
Textures
Brands
Misc
Music
Other
Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .