0

I'm building a refinery cms application and I'm trying to add an alternative log in screen that will consume a .NET webservice. However while the code for consuming the service was simple enough I can't seem to get rails or refinery to acknowledge that the view for it actually exist and thus no route that I enter into the url will take me to the view for the alternate log in and I can't figure out why. The file for my view is located at /views/sessions/dotnet.html.erb and currently my sessions_controller.rb contains the definition for the method

class SessionsController < ::Devise::SessionsController
   .
   .
   .
  def create
    super
    rescue ::BCrypt::Errors::InvalidSalt, ::BCrypt::Errors::InvalidHash
      flash[:error] = t('password_encryption', :scope => 'users.forgot')
      redirect_to new_user_password_path
  end

  def dotnet
    .
    .
    .
  end
   .
   .
   .
end

and the routes.rb file without the comment lines looks like:

Quicksmile::Application.routes.draw do
   resources :sessions

   resources :dotnetwrappers

   match "/" => redirect("/new-practices")

end

I have tried the methods here and here but neither of them worked. How do I set it up so that there is actually a url corresponding to the /views/sessions/dotnet.html.erb file?

Community
  • 1
  • 1
Working Title
  • 254
  • 7
  • 28
  • Well I found out my routes aren't working because any routes that conflict with routing file in the refinery cms gem get overriden when the application start (as opposed to the other way around). Now I just have to figure out how to fix that. – Working Title May 09 '12 at 13:05

1 Answers1

1

It doesn't look like you've actually added a route for SessionsController#dotnet.

You'll need something like:

Quicksmile::Application.routes.draw do
  resources :sessions
  get :dotnet_login => "sessions#dotnet", :as => "dotnet_login"

  # ...
end

Then you can use the URL helpers main_app.dotnet_login_path and main_app.dotnet_login_url inside your code.

More details to be found at the Rails Routing Guide.

  • Doesn't work. I get a message saying lib/active_support/whiny_nil.rb:48:in `method_missing': undefined method `to_sym' for nil:NilClass (NoMethodError) – Working Title May 04 '12 at 18:32
  • Try replacing that third line with: `get '/dotnet_login' => "sessions#dotnet", :as => "dotnet_login"` – Rob Yurkowski May 06 '12 at 00:59
  • Well that worked kind of. After navigating to /dotnet_login I get taken to a page saying "Could not find devise mapping for path "/dotnet_login". Maybe you forgot to wrap your route inside the scope block? For example: devise_scope :user do match "/some/route" => "some_devise_controller" end" – Working Title May 07 '12 at 14:19