rails-routing

Ruby on Rails: Get the controller and action name based on a path

I am trying to get the controller and action name based on a path. I have a route: map.resources :permissions I thought that I could use: ActionController::Routing::Routes.recognize_path "/permissions/1" To get a hash like: { :controller => "permissions", :action => "show" } The actual hash that comes back is: { :controller => ...

Access two models in one view in Rails

Background: I'm trying to create a simple feed reader for which I'm using the feedzirra. I am developing in Rails 3. This is probably pretty simple, but I'm trying to figure out how to access the contents of two related models from a single view. The model relationship is as follows: Feed has_many Entries Entry belongs_to Feed Thanks...

Rails: how to create a default route for specific object

I have a User class and map.resources :users in my routes. If I create a link link_to @user.name, @user It will somehow automatically create a link to /users/3 where 3 is an ID of the user. What if I want to create more userfriendly links and identify users not by IDs but by their usernames. So path would look like /users/some_user...

/session instead of /login when login attempt failed

sessions_controller.rb def create if user = User.authenticate(params[:login], params[:password]) session[:user_id] = user.id redirect_to posts_path else render :action => 'new' end end routes.rb get "sessions/create" get "sessions/destroy" get "sessions/new" resources :posts resource :ses...

Overriding a resource route to / (root) in Rails3: not changing the path helper?

Hi, I am quite new to Rails3, I basically created a subscribers scaffolding, I only want my app to respond to new and create actions. So in config/routes.rb I defined: resources :subscribers, :only => [:new, :create] Which works this way GET /subscribers => subscribers#new POST /subscribers => subscribers#create Now I want my a...

Why is the route not finding the the decimal

Ok so i have an application that i use this jquery $("#band_events").load("/load_events/"+ escape($('#request_artist').val()), successCallback ); It works great but if #request_artist is R.E.M. or somehthing with decimals or something weird rails has problems like ActionController::RoutingError (No route matches "/load_events/R.E.M....

Problem with same resource, accessible via two routes.

I'm developing simple image sharing site to train my ruby-on-rails-fu. I have following resources in my config/routes.rb file. resources :users do resources :images end resources :images Here's the problem I'm facing - how should I go about implementing functionality like "latest images" and "your image subscriptions"? Having vanil...

convert array of parameters from form into string

I have a form with a checkboxes: -form_tag filter_path(@page.permalink), :method => 'get' do |f| -ftype.producers.each do |producer| =check_box_tag "producers[]", producer.id, false =label_tag producer.title %br =submit_tag 'Сортувати', :name => nil When I send a request, it sends a hash params with an array of...

rails 3 best approach multiple apps within one app

I have a rails 3 app that has 2 different UIs that both share the same model but have different UIs. Lets call these retailers and customers "sites". What is the best approach in rails 3 for creating a monolithic application to keep these two apps in one app. Should I just namespace the controllers, and change routing as such? namesp...