rails-routing

How can I make routes from a Rails 3 engine available to the host application?

浪子不回头ぞ 提交于 2020-01-01 01:53:07
问题 I have a Rails 3 application with several engines containing additional functionality. Each engine is a separate service that customers can purchase access to. I am, however, having a problem with routes from the engines that aren't readily available to the controllers and views. controller: class ClassroomsController < ApplicationController .. respond_to :html def index respond_with(@classrooms = @company.classrooms.all) end def new respond_with(@classroom = @company.classrooms.build) end ..

rails remove controller path from the url

谁说胖子不能爱 提交于 2019-12-30 10:30:16
问题 I have the following loop in my view <% @posts.each do |post| %> <%= link_to post do %> Some html <% end %> <% end %> The above code will generate link as localhost:3000/posts/sdfsdf-sdfsdf But I would like to have the link as localhost:3000/sdfsdf-sdfsdf Here is my route resources :posts, except: [:show] scope '/' do match ':id', to: 'posts#show', via: :get end 回答1: You could do this: #config/routes.rb resources :posts, path: "" #-> domain.com/this-path-goes-to-posts-show -- Also, make sure

Rails query string with a period (or full stop).

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-29 01:37:19
问题 I am currently trying to get a handle on RoR. I am passing in two strings into my controller. One is a random hex string and the other is an email. The project is for a simple email verification on a database. The problem I am having is when I enter something like below to test my page: http://signup.testsite.local/confirm/da2fdbb49cf32c6848b0aba0f80fb78c/bob.villa@gmailcom All I am getting in my params hash of :email is 'bob' . I left the . between gmail and com out because that would cause

Rails Post method redirecting to edit action rather than create

烈酒焚心 提交于 2019-12-25 07:40:52
问题 I am writing a small rails application and I am attempting to add the ability to for users to reset their passwords in a method similar to rails cast 274 (http://railscasts.com/episodes/274-remember-me-reset-password). I was able to add this functionality, but it now seems to have broken. I have a link to a reset_password form from the signin page. The rails code is below: <h1>Reset Password</h1> <%= form_tag password_resets_path, :method => :post do %> <div class="field"> <%= label_tag

Rails app saying can't find users route, should be working

放肆的年华 提交于 2019-12-25 05:03:49
问题 I have having a problem logging into my existing app with custom authorization. When I login, I get the error No route matches {:action=>"show", :controller=>"users", :locale=>#<User id: 4, first_name: "asd", last_name: "asd", email: "c@c.com", password_digest: "$2a$10$FDkc/CkjbwS455r/s.OF9uXUzuRmzz3zsYEejij.0KCT...", access_level: 3, last_login Here is my routes file Islasdelsol::Application.routes.draw do scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do root :to => 'sites

Routing Error when used Authlogic with Rails 3.2.9

百般思念 提交于 2019-12-25 04:47:10
问题 I have configured authlogic gem for user management needs by referring https://github.com/jonathandean/authlogic_example. I have configured everything correctly. I am using Rails 3.2.9 and ruby 1.8.7. I am getting the following error when I took localhost:3000 Routing Error undefined method `filter_parameter_logging' for ApplicationController:Class Try running rake routes for more information on available routes. Please help to resolve this. Thanks for any help :)- 回答1: I got the problem

Ruby on Rails 3.2.13 - Getting Error With Custom Error Pages Using I18n

瘦欲@ 提交于 2019-12-25 00:43:25
问题 I have a Rails 3.2.13 application where I originally used the routing-filter gem for I18n. I plan to rewrite it in Rails 4. I removed the gem since there is no Rails 4 production version available and I could not get the beta version to work. I was successful in getting the routing set up for most of the application. The only problem I am having is with my custom error pages. I created custom error pages when I was using the routing-filter gem. I need help on how I should set up my routes for

Application Controller not being executed when accessing domain without redirect in router.rb to default locale

六月ゝ 毕业季﹏ 提交于 2019-12-25 00:28:25
问题 Using locale in my rails app. I have the following routes.rb scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do root to: 'static_pages#home' devise_for :users, :controllers => { :registrations => :registrations } resources :blogs do resources :comments end get 'tags/:tag', to: 'blogs#index', as: :tag resources :users get '/users/subregion_options' => 'users#subregion_options' resources "contacts", only: [:new, :create] match '/crew', to: 'static_pages#crew', via: 'get' .... end

Rails RSpec request spec fails because unexpected %2F added to redirect response

寵の児 提交于 2019-12-24 17:08:09
问题 In config/routes.rb: get 'books(/*anything)' => redirect( "/public/%{anything}" ), :format => false In spec/requests/store_request_spec.rb: get '/books/aoeu/snth' expect(response).to redirect_to( '/public/aoeu/snth' ) This fails with: Failure/Error: expect(response).to redirect_to( '/public/aoeu/snth' ) Expected response to be a redirect to <http://www.example.com/public/aoeu/snth> but was a redirect to <http://www.example.com/public/aoeu%2Fsnth>. Expected "http://www.example.com/public/aoeu

rails routes with :id not working

邮差的信 提交于 2019-12-24 14:22:00
问题 I have a model called Schedule that belongs_to a project. A project has_one schedule. I am trying to follow CRUD conventions but having some difficult. I have a page that lists all the projects and has a link next to each project to create a schedule. I started out with the following in my route file: resources :schedules Here's the problem. In the url of the 'new schedule' page there needs to be an :id that refers to the project that the schedule belongs to, that way when the schedule is