I am trying to get basic authentication working using devise and mongomapper.
Following the instructions here:
http://johnwyles.com/2010/03/15/sessions-in-mongodb-using-mongomapper-and-devise/
(except deferring the routes.rb changes until after the generators are run to address errors)
I got it as far as getting the following paths to work:
/users/sign_up ::
/users/sign_in ::
/users/password/new ::
/users/confirmation/new
However, just trying to hit "/" gives me an error
NameError in UserController#sign_in
uninitialized constant UserController
RAILS_ROOT: /Users/bentrevino/Documents/Dev/devisetest
Application Trace | Framework Trace | Full Trace
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/inflector.rb:364:in `constantize'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/inflector.rb:363:in `each'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/inflector.rb:363:in `constantize'
/Library/Ruby/Gems/1.8/gems/activesupport-2.3.8/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:444:in `recognize'
/Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:437:in `call'
After I submit a sign-up request, I get this error
RuntimeError in Registrations#create
Showing /Library/Ruby/Gems/1.8/gems/devise-1.0.8/app/views/devise_mailer/confirmation_instructions.html.erb where line #5 raised:
Missing host to link to! Please provide :host parameter or set default_url_options[:host]
Extracted source (around line #5):
2:
3: <p>You can confirm your account through the link below:</p>
4:
5: <p><%= link_to 'Confirm my account', confirmation_url(#resource, :confirmation_token => #resource.confirmation_token) %></p>
Does anybody know what might be going on here?
Thanks!
Ben....
At least one issue you are having is that you have not created a controller for your root route that you specified in config/routes.rb file. Run a call to rails generate controller [name] to make a new controller. Then specify that name in your config/routes.rb file for our root route.
Related
I have a database I created in ruby on rails which automatically created some of the needed files but when I manually added an additional file in the views folder and try to access it in my browser .
This error appears
Routing Error
No route matches [GET] "/second/count"
Try running rake routes for more information on available routes.
I tried to correct this by putting a number sign in the routes.rb
Community::Application.routes.draw do
#resources :seconds
match ':controller(/:action(/:id))', :via => :get
The file I just created worked but then the files automatically created won't.
This error appears
NameError in Seconds#index
Showing c:/Sites/Community/app/views/seconds/index.html.erb where line #25 raised:
undefined local variable or method `new_second_path' for #<#<Class:0x456ee80>:0x37b9a98>
Extracted source (around line #25):
22:
23: <br />
24:
25: <%= link_to 'New Second', new_second_path %>
Rails.root: c:/Sites/Community
Application Trace | Framework Trace | Full Trace
app/views/seconds/index.html.erb:25:in `_app_views_seconds_index_html_erb__742794588_29296056'
app/controllers/seconds_controller.rb:7:in `index'
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
For the helper new_second_path to work, you have to uncomment the line resources :seconds in the routes.
Unless you know what you are doing, I would comment the line match ... which is a catch-all.
Also: a path /second/count will not work, it should be /seconds/count. To explain this:
/second/count: with your match it will look for SecondController (singular!!) and action count
But the clean way to handle is to write:
resources :seconds do
collection do
get :count
end
end
This will allow you to write count_seconds_path in your view, which will render the correct link (/seconds/count).
I am newbie with Shapado. I’m trying to install shapado in my laptop (MAC OS) and when I try to access to http://localhost.lan:3000 I have the following error:
NoMethodError in Questions#index
Showing /Users/sciruela/Documents/shapado/shapado/app/views/shared/_login_drop_down.html.haml where line #10 raised:
undefined method `[]' for nil:NilClass
Extracted source (around line #10):
7: = link_to provider.titleize, '/users/auth/facebook', :class => 'auth-provider Facebook', :id => 'facebook'
8: - else
9: %li
10: = link_to provider.titleize, multiauth_url(provider), :class => "auth-provider #{provider}", :id => dprovider
11:
12: -if current_group.allow_any_openid
13: %li
Trace of template inclusion: app/views/shared/_login_menu.html.haml, app/views/shared/_topbar.html.haml, app/views/layouts/application.html.haml
Rails.root: /Users/sciruela/Documents/shapado/shapado
Application Trace | Framework Trace | Full Trace
app/views/shared/_login_drop_down.html.haml:10:in `block in _app_views_shared__login_drop_down_html_haml__1123238317393261506_2159776840'
app/views/shared/_login_drop_down.html.haml:2:in `each'
app/views/shared/_login_drop_down.html.haml:2:in `_app_views_shared__login_drop_down_html_haml__1123238317393261506_2159776840'
app/views/shared/_login_menu.html.haml:6:in `_app_views_shared__login_menu_html_haml___434956048083202339_2193663100'
app/helpers/application_helper.rb:36:in `multiauth_dropdown'
app/views/shared/_topbar.html.haml:21:in `_app_views_shared__topbar_html_haml___2782218627514502243_2204427320'
app/views/layouts/application.html.haml:10:in `block in _app_views_layouts_application_html_haml___4514694021451724572_2205033860'
app/helpers/layout_helper.rb:74:in `call'
app/helpers/layout_helper.rb:74:in `block in ie_tag'
app/helpers/layout_helper.rb:72:in `ie_tag'
app/helpers/layout_helper.rb:79:in `ie_html'
app/views/layouts/application.html.haml:2:in `_app_views_layouts_application_html_haml___4514694021451724572_2205033860'
app/controllers/application_controller.rb:122:in `block (2 levels) in find_questions'
app/controllers/application_controller.rb:121:in `find_questions'
app/controllers/questions_controller.rb:67:in `index'
lib/sso_strategy.rb:18:in `call!'
app/middlewares/dynamic_domain.rb:17:in `call'
Request
How I could solve it?
Thanks
In Rails, the [] acts as a reader and []= as a setter. It looks like the issue is occurring on line 10 at multiauth_url(provider).
It also appears that provider is nil in this case. I suggest using pry (a gem) and drop in binding.pry to debug further. You might be making the assumption that a provider always exists, so verify that provider is not nil first.
did you follow shapado's Readme? seems like you did not this step
https://github.com/ricodigo/shapado/blob/master/README#L25
The scaffold command is the following
ruby script\generate scaffold Leave employee_id:integer leave_type_id:integer date:date
I know I could change the name but I just wonder why it always throws undifined new_leave_path
Glad to know your brilliant thoughts.
Below is the full details of the error:
NameError in Leaves#index
Showing app/views/leaves/index.html.erb where line #26 raised:
undefined local variable or method `new_leave_path' for #<ActionView::Base:0x620ea70>
Extracted source (around line #26):
23:
24: <br />
25:
26: <%= link_to 'New leave', new_leave_path %>
Application trace:
app/views/leaves/index.html.erb:26
app/controllers/leaves_controller.rb:7:in `index'
rake routes
new_leafe_path
or
map.resources :leaves, :singular => :leave
)
#insic Hi
It is just working fine on my machine. may be there are some conflicts with any gem or plugin that you might be using. Can't explicitly find out what is the exact reason, as I am a newbie to rails.
Add
#routes.rb
map.resources :leaves
I have the following controller
class ActiveUsersController < ApplicationController
def edit
end
end
And my routes.rb is like this:
map.resources :active_users
When I try to access the controller using the url http://localhost:3000/active_users/COo8e45RqQAHr6CqSCoI/edit I got the following error:
NameError in Active usersController#edit
uninitialized constant ActiveUsersController
RAILS_ROOT: /Users/vintem/Documents/Projetos/Pessoal/bugfreela
Application Trace | Framework Trace | Full Trace
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:443:in `load_missing_constant'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in `const_missing'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:361:in `constantize'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `each'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/inflector.rb:360:in `constantize'
/Users/vintem/.gem/ruby/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/string/inflections.rb:162:in `constantize'
/Users/vintem/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:443:in `recognize'
/Users/vintem/.gem/ruby/1.8/gems/actionpack-2.3.5/lib/action_controller/routing/route_set.rb:436:in `call'
Can anyone help me?
Thanks
resources refers to the model and an assumed correlate controller named similarly. Do you have an ActiveUser model class? Or is it something else, say User? E.g.:
map.resources users, :controller => "active_users"
Check out the API docs:
http://api.rubyonrails.org/classes/ActionController/Resources.html
Hard to tell exactly what's wrong from the info you've provided.
I am a complete newbie to the world of Ruby & Rails moving from the land of PHP & Symfony. I'm currently attempting to setup the Facebook Connect plugin & Twitter oAuth for authlogic. Authlogic works no problem but both of the others fail when I attempt to call their buttons- can someone tell me where I'm going wrong? I've put the stack trace below- thanks!
NameError in User_sessions#new
Showing app/views/user_sessions/new.html.haml where line #13 raised:
undefined local variable or method `authlogic_facebook_login_button' for #<ActionView::Base:0x1034fe9e0>
Extracted source (around line #13):
= f.text_field :password
%br
= f.submit "Login"
= authlogic_facebook_login_button
RAILS_ROOT: /Users/nick/Sites/matchmefor-2
Application Trace | Framework Trace | Full Trace
/Users/nick/Sites/matchmefor-2/app/views/user_sessions/new.html.haml:13:in `_run_haml_app47views47user_sessions47new46html46haml'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/haml/helpers/action_view_mods.rb:164:in `call'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/haml/helpers/action_view_mods.rb:164:in `form_for'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/haml/helpers.rb:543:in `call'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/haml/helpers.rb:543:in `haml_bind_proc'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/haml/helpers/action_view_mods.rb:170:in `form_for'
/Users/nick/Sites/matchmefor-2/app/views/user_sessions/new.html.haml:4:in `_run_haml_app47views47user_sessions47new46html46haml'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/haml/helpers/action_view_mods.rb:13:in `render'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/haml/helpers/action_view_mods.rb:13:in `render'
/Library/Ruby/Gems/1.8/gems/haml-2.2.9/lib/sass/plugin/rails.rb:19:in `process