similar to: Setting a global before_filter action in application.rb

Displaying 20 results from an estimated 7000 matches similar to: "Setting a global before_filter action in application.rb"

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 May 30
5
Implementing HTTPS with WEBrick?
All, I would like to test some secure pages that I''m developing in my WEBrick-based development environment. I''ve done some research and it appears that I need to create a new command that will start a HTTPS based WEBrick server. Is this correct? Also, it appears that the https.rb module is not included with the WEBrick bundled in Rails. So, I will need to go get that
2013 Feb 14
1
create object after before_filter :authenticate_user!
hi I use devise and cancan my model class PostsController < ApplicationController before_filter :authenticate_user!, only: [:create, :update, :destroy] ... end so an unauthentificate user can access new post form. Now when unauthentificate user submit new or edit forms, he is redirected to login form. But when he logs in, his post is not save in database. Is there anythings to do such
2008 May 06
12
Why before_filter is not working?
I have been scratching my head on this one for most of the day. Hopefully someone can help explain why before_filter isn''t working for my codes. In my Application controller, I have this: before_filter :login_required, :except => [:newacct, :create_newacct, :passwd_reset ] def login_required unless session[:user_id] flash[:notice] = "Please log in"
2007 Dec 03
2
before_filter application => exclude some other controllers
Hello again, It''s possible to use before_filter in the application_controller, and exclude for some methods from other controllers ? i have a before_filter in application_controller that checks if the user is logged, if the time hasn''t expired, ... and I want to exclude some methods of this check, like the login. This ''login'' belongs to other controller. I
2008 Dec 19
2
before_filter for a specific controller/action
I''m learning about before_filter, implementing a simple "you must be logged on" thing. It works great, but I need to allow people to create a player as well. By writing the except as attached, that works, but then everyone has access to all "new" methods, which I don''t really want. Can someone help me with how to properly construct this to limit non-logged
2007 Mar 20
1
Passing Arguments to before_filter
I want to put a before_filter in application.rb, as follows: before_filter :do_something, :except_controller => [:admin] def do_something(options) options.stringify_keys! unless options[:except_controller].include?(controller_name) # do something useful end end Where I''m blocking is on how to get the ''options'' data in the do_something method. I think I
2006 Mar 30
1
flash, before_filter and redirect_to
I leave a notice in the flash and do a redirect from a before_filter. Can someone confirm that the first request after this, i.e. the page I redirect to, doesn''t/isn''t supposed to clear the flash? -- View this message in context: http://www.nabble.com/flash%2C-before_filter-and-redirect_to-t1367103.html#a3665933 Sent from the RubyOnRails Users forum at Nabble.com.
2006 Mar 27
3
regular expression matching in routes.rb
All, I have a route specified as: map.connect '':folder/:filename'', :folder => /htmlfiles/, :controller => "eSimply", :action => "preview_HTML" I expect it to invoke the "preview_HTML" action in the "eSimply" controller. Given an argument of "htmlfiles/xyz.html", it keeps saying that it can''t find an
2006 Mar 27
3
Specify a controller action via attribute in INPUT tag?
I have a pre-existing form with one existing "SUBMIT" tag generated by <%= submit_tag %> I would like to add another <INPUT type="submit" ...> to my form. How do I successfully associate that <INPUT> tag with a different controller action than the default one specified by my <%= start_form_tag %>? Or does this approach even make sense? In RoR, is
2008 Mar 19
7
Upgrade to 2.0.2: InvalidAuthenticityToken error on 1st POST
All, I''ve upgraded to 2.0.2, and I can''t get my login screen (the first POST request in the application) to work. When I post this form, I see the "InvalidAuthenticityToken" error. I have protect_from_forgery :secret => ''my_secret'' set in application.rb and I am using an active_record session store based on this line in environment.rb:
2006 Mar 18
9
Using <%= text_field %> within partials is problematic
All, Thanks for any help in advance. I have what I think is a very straightforward partial template and I can''t figure out why a text_field call within it doesn''t work. Here is my calling template: lists.rhtml <div id="target_lists"> <%= render(:partial => "target_lists", :collection => @target_lists) %> </div> In the partial
2006 Jul 10
8
Setup new data in the test database _after_ unit test runs
All, I want to run automated unit tests as part of my build. I am building to my test environment. Upon successful completion of all of my unit tests, I would then like to load some data (using a fixture, I imagine) into my test database that will act as fresh "system test" data for my users to play with. What is the best way to "load the standard system test/user acceptance
2006 Feb 04
22
What''s the best way to embed a form?
I would like to embed my login form on my app''s home page. What''s the best way to render the login action of member controller from another action? Thanks Frank --------------------------------- Relax. Yahoo! Mail virus scanning helps detect nasty viruses! -------------- next part -------------- An HTML attachment was scrubbed... URL:
2006 Jul 13
5
Generic page element display initializer in a layout?
All, I''ve run into a snag. I need to handle the display of elements on my page and I want to use my Javascript event handlers on page load. However, my BODY tag is trapped in my generic layout. I''m thinking that I can put an onLoad on the BODY tag that will just call a Javascript method called initializePage() and then provide this initializePage() call in my specific page
2006 Mar 22
6
Relatively easy HTML/XML parsing utilities?
Anyone know of any Ruby modules which can be used to parse an HTML page ? Thanks, Wes -- Posted via http://www.ruby-forum.com/.
2006 Jul 03
4
text_field doesn''t call overridden ActiveRecord getters
All, In a template, I have <%= text_field :target_list, :DateReceived, { :title => ''uploaded_at'', :class => ''target_list_info'', :disabled => ''true'' } %> Here is the DateReceived method on my
2006 Jul 14
7
Form validation - keepin correct fields displayed on refresh
All, I''m finally doing my first real form in Rails - the model object that I''m entering information for has 8 validations so far. If I type in good values for all the fields but one, I get the pretty validation, and the nice field highlighting, but all of the fields are cleared, forcing me to retype all of that info. That is a big drag. Is there a standard way to get the
2006 Mar 20
5
Wrap error_messages_for() call when no instance var present
I am trying to put some smarts around a call to <%= error_messages_for %> so that when I first come into this page i.e. when my instance variable @target_list has not been defined yet, the page doesn''t break. I''m doing this: <% if @target_list? %> <%= error_messages_for ''target_list'' %> <% end %> I get a syntax error on line 1.
2006 Jul 10
7
What is has_many :through really buying you over HABTM?
So having just learned how to do has_many :through as opposed to HABTM, and then, being concerned that I wouldn''t get it to work, I started thinking about these two approaches. It seems to me that the _only_ problem that the HM:T (has_many :through) approach solves that HABTM doesn''t is the issue of the potential collision of id columns between your join table and one of