Skip to content

Instantly share code, notes, and snippets.

@ch1ago
Created September 26, 2015 04:04
Show Gist options
  • Save ch1ago/3345577befa1b5ec2b58 to your computer and use it in GitHub Desktop.
Save ch1ago/3345577befa1b5ec2b58 to your computer and use it in GitHub Desktop.
<ul class="nav nav-pills pull-right">
<li><%= link_to human_current_locale, hello.locale_path %></li>
<li><%#= link_to "User List", main_app.users_path %></li>
<li><%= link_to "User List", users_path %></li>
<% if current_access_tokens.any? %>
<li><%= link_to "Switch Accounts", hello.accounts_path %></li>
<% end %>
<% if signed_in? %>
<% if current_user.webmaster? %>
<li><%= link_to "Web Master Dashboard", hello.webmaster_path %></li>
<% end %>
<li><%#= link_to "My Profile", main_app.url_for(current_user) %></li>
<li><%= link_to "My Profile", current_user %></li>
<li><%= link_to "Settings", hello.current_user_path %></li>
<li><%= link_to "Sign Out", hello.sign_out_path %></li>
<% if impersonated? %>
<li><%= link_to "Back to Myself", hello.impersonate_back_webmaster_users_path %></li>
<% end %>
<% else %>
<li><%= link_to "Sign Up", hello.sign_up_path %></li>
<li><%= link_to "Sign In", hello.sign_in_path %></li>
<li><%= link_to "Forgot Password", hello.password_forgot_path %></li>
<% end %>
</ul>
in this error, don't want to prepend main_app to every app-route.
this happens because the view template was loaded from an Engine controller
this is really annoying as it would force the end-developer to scope all of his app routes into main_app
9) Hello Gem Vision: Be a great Rails User Registration Open Source Library Goal: Authentication Capability: Email Sign In Feature: Single Form Context: Invalid Scenarios Scenario: Blank Password
Failure/Error: when_sign_in("foobar", "")
ActionView::Template::Error:
undefined local variable or method `users_path' for #<#<Class:0x007fcffb46cc88>:0x007fcffd182070>
# ./app/views/hello/shared/_nav_pills.html.erb:3:in `___sers_tj_github_hello_gem_hello_app_views_hello_shared__nav_pills_html_erb___3212978994574606722_70265653545820'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/template.rb:145:in `block in render'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/activesupport/lib/active_support/notifications.rb:166:in `instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/template.rb:333:in `instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/template.rb:143:in `render'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/renderer/partial_renderer.rb:339:in `render_partial'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/renderer/partial_renderer.rb:310:in `block in render'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/renderer/abstract_renderer.rb:39:in `block in instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/activesupport/lib/active_support/notifications.rb:164:in `block in instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/activesupport/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/activesupport/lib/active_support/notifications.rb:164:in `instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/renderer/abstract_renderer.rb:39:in `instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/renderer/partial_renderer.rb:309:in `render'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/renderer/renderer.rb:47:in `render_partial'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/helpers/rendering_helper.rb:35:in `render'
# ./spec/dummy/app/views/layouts/application.html.erb:22:in `_app_views_layouts_application_html_erb___3946290121287052242_70265631018640'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/template.rb:145:in `block in render'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/activesupport/lib/active_support/notifications.rb:166:in `instrument'
-- before
<ul class="nav nav-pills pull-right">
<li><%= link_to human_current_locale, hello.locale_path %></li>
<li><%#= link_to "User List", users_path %></li>
--now
<ul class="nav nav-pills pull-right">
<li><%= link_to human_current_locale, locale_path %></li>
<li><%#= link_to "User List", main_app.users_path %></li>
now we get a different version of the same error.
we will unscope all paths within the gem hello
and only scope the app paths within main_app
however, when we try to load the view template on an App controller,
it doesn't recognize all of those methods from the engine hello.
Failure/Error: when_sign_in_with_standard_data(keep_me: true)
ActionView::Template::Error:
undefined local variable or method `locale_path' for #<#<Class:0x007faa14972028>:0x007faa18d2d9c0>
# ./app/views/hello/shared/_nav_pills.html.erb:2:in `___sers_tj_github_hello_gem_hello_app_views_hello_shared__nav_pills_html_erb___3618284488160606931_70184223134440'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/template.rb:145:in `block in render'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/activesupport/lib/active_support/notifications.rb:166:in `instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/template.rb:333:in `instrument'
# /Users/tj/.rvm/gems/ruby-2.2.2/bundler/gems/rails-42b0c942520e/actionview/lib/action_view/template.rb:143:in `render'
# Engine routes are always scoped
# App routes are never scoped
<ul class="nav nav-pills pull-right">
<li><%= link_to human_current_locale, hello.locale_path %></li>
<li><%= link_to "User List", users_path %></li>
<% if current_access_tokens.any? %>
<li><%= link_to "Switch Accounts", hello.accounts_path %></li>
<% end %>
<% if signed_in? %>
<% if current_user.webmaster? %>
<li><%= link_to "Web Master Dashboard", hello.webmaster_path %></li>
<% end %>
<li><%= link_to "My Profile", current_user %></li>
would you please help me solve this situation?
I have been working on this open source project for 18 months now and I am ready to make a release.
Thank you :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment