similar to: Getting name of currently rendering ERb template in view?

Displaying 20 results from an estimated 6000 matches similar to: "Getting name of currently rendering ERb template in view?"

2006 Jun 27
5
Can''t call public application.rb method from ERb template
All, I have a left navigation partial that I want to dynamically generate CSS classes for based on the current controller action. In my ERb template, I have <DIV class="<%= get_menu_display_style(''login_form'') %>"> In application.rb, I have the method get_menu_display_style defined as: public def get_menu_display_style(action_requested)
2006 Apr 27
3
Routing problem
Hi, I am having a routing problem and can''t figure out why its happing. I have added the following line in my routing.rb file. map.connect ''name/:id'', :controller => ''controller_name'', :action => ''action_name'' When I use http://domain.com/controller_name/action_name/id then it works fine on the local machine using webrick
2006 Jan 02
2
Dynamic form tags
Hi all, I''m happily using "HowToReuseEditViewsForNewViews" found at: http://wiki.rubyonrails.com/rails/pages/HowToReuseEditViewsForNewViews There''s this comment there saying you only need the tag "<%= auto_form %>" when using the code below. Can somebody tell me if that will work when extending it with model_name (some how)? I have several new_*
2006 Sep 22
6
Using after_filter to control rendering on actions
I have a common failure page that I may need to render to upon failing some test that occurs in an after_filter method. I''d like to use the after_filter to take over the control of the rendering, like so: def test_for_validity some_boolean = my_test return render(:action => ''disqualified'') unless some_boolean @success_controller ||= controller_name
2007 Jul 24
4
spec''ing helpers that use controller
Hi all, I''m in the process of creating rspecs for my helpers. One of the helpers in app/helpers/application_helper.rb looks like this: def page_name @page_name || "Define @page_name in #{controller.controller_name}::#{controller.action_name}" end The rspec is simply: it "should something" do page_name end
2006 Jul 09
1
Accessing the name of a controller''s module?
If I''m redirecting to a log in page, and saving the controller and action name in the session hash, how do I also save the controller module? After the log in is completed, I can''t redirect back to the originally directed page because it''s in a different controller module. For the controller action name I can use the ActionController instance method controller_name(),
2007 Mar 21
0
Getting the module name with ObjectSpace...
Hey :) I''m trying to create a method for making a sitemap dynamically. It works great for flat sites where you simply have your controllers in the app/controllers directory. In this case, I can extract the controller names like, @controllers ObjectSpace.subclasses_of(ActionController::Base).each do |obj| @controllers["#{obj.controller_name}"] = obj end However,
2006 Jul 12
3
How to get the current URL?
Hi, how can I get the current URL withing a controller? There seems to be no appropriate method in ActionController::Base. I''m creating a site, which requires a login for some pages. I''m using before_filter for authentication. My idea was to store the currect URL in a session before redirecting to the login page and then redirect to this URL after successful authenfication.
2008 Dec 07
2
Strange 500 Error with namespace::controller#action appearing in reload only
The portion of the log linked below is two requests directly out of the log file for the same action. The first request was from me putting the address in the browser directly (but can be duplicated by linking to the url anywhere in the app). When I reload the browser on this url, I get a strange error. To the user, the action appears to load fine, but I''m getting a 500 error in the log
2006 Jan 03
1
RequireResourceHelper for JS and CSS
The following was posted on my blog at http://blog.inquirylabs.com. A friend of mine recently expressed interest in this code snippet, so I thought I''d send it out to anyone else who''s interested. This module makes it a lot easier to ''require'' javascript and cascading stylesheet dependencies inside your views or controllers. By
2006 Apr 05
2
Return Rendering Controller In View
I have a shared partial which could be rendered by two different controllers. Is there an easy way in the view to return which controller rendered the partial? I''ve tried using: <%debug(params[''controller''])%> While that does return what I need it seems like a kludgy fit since debug is not meant to be used for that. Thanks, LarsenMTL -- Posted via
2006 Jul 22
4
Accessing the controller name in your views?
I need to know what controller and action the user is currently in to do various things in my layouts/application.rhtml file. Isn''t there is a better way than: <% if params[:controller] == "whatever" && params[:action] == "whatever" %>some html<% end %> I know in the controllers you can just use controller_name, but that is not provided
2006 Jul 02
3
2 before_filters, only want one to render something
I have two before_filters for a few of my controllers. They are running my own methods authorize and admin_authorize. authorize is called on just about every action to make sure that a user is logged in. admin_authorize is called on about 80% of the actions and is used to make sure that a user is an administrator. If a user tries to access an admin_authorize protected action without being
2007 Jul 26
6
response.should_not redirect_to
Hey, May be it is just too deep night over here and I''m missing something though I got this failure on {{{response.should_not redirect_to}}}: ''QueuesController should allow authenticated user to access ''show'''' FAILED Matcher does not support should_not. See Spec::Matchers for more information about matchers. Also I''ve found this in
2006 Jun 30
8
before_filter: nil vs. true vs. false
Folks, My understanding of how filters work is that I should return true if everything is ok and false if not. How does the filter below work then (from the Rails Recipies book)? It would return nil if there''s a user in the session. Does nil count as true? before_filter :check_authentication def check_authentication unless session[:user] session[:intended_action] =
2006 Mar 22
4
Problem with ACL plugin system
Don''t know if anyone else has experienced this but I''m having a problem with the access_denied method in Ezra''s ACL access control plugin. It''s working fine (in conjunction with acts_as_authenticated) until it comes across a user it denies access to, in which case it throws the following error: NoMethodError in Admin#index protected method
2013 Apr 12
0
Rails Log user in after view rendered
I have an apply view (index page) where the user can leave his credentials if he applies from that views an account will be generated an the user will be logged in. And an overview page will be shown (create page) But if he is already logged in and applies the sentence "we have send your password to ... cannot be shown in my view. So I have made the following: <% unless
2006 Apr 25
0
completely stuck on Role-Based Authorization
Im completely stuck on Role-Based Authorization (I used the rails recipe method) (user_controller.rb) def login return if generate_blank @user = User.new(@params[''user'']) if @session[''user''] = User.authenticate(@params[''user''][''login''], @params[''user''][''password''])
2006 Mar 01
0
link_to problem when used in folder
I have split my appliction into 2 folders - public and restricted areas: "site" and "admin" Now, in "site" i have a "search" controller with the "results" action. I want to make a link that will keep all the parameters of the link <%= link_to ''link'', params %> However, instead of something like:
2006 Mar 02
1
Coding conventions (mostly AR)
I have the following tables: Users, Clients, Roles, Assignments(user_id, role_id, client_id) and Rights(controller, action). First of all, I''d like to know if hooking things up this way makes any sense. Could perhaps add a second join table between assignments and roles, but not sure that would add any value. What i''m really wondering about, though - is how to do things the