similar to: a user model in all controllers in 6 lines of code

Displaying 20 results from an estimated 9000 matches similar to: "a user model in all controllers in 6 lines of code"

2006 Jun 27
0
More idiomatic way of doing this
Folks, I''m trying to write a validating filter that checks if the user exists and renders XML if not. Most of the controllers will be returning XML on some error or other so I''m including RenderError in ApplicationController. Is my approach a sound one? Also, is there a shorter and more idiomatic way of writing this: if @user.nil? render_user_exists
2006 Jul 14
4
sending additional parameters to before_filter
i am trying to create a system so that different users have different priviliges on my application. i was going to modify my authorize function so that i could pass the required role to it and have it check the current user for that role. i am using before_filter and would like to have just one function instead of writing one for each role like so: authorize(role) instead of:
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all actions...and their views? eg. class ApplicationController < ActionController::Base @current_user = User.find(session[:user_id]) end and everywhere I can call @current_user.id and I can get that object? Even down in the views? I could not get this to work... Thanks in advance, Jeff -------------- next part
2009 May 15
0
[PATCH server] final cleanup for service layer refactoring.
I've pulled out the no-longer-necessary remnants of the old way of handling auth and before_filters as well as fixing a couple bugs that had crept in along the way. Unit test fixes for the refactoring will follow in a subsequent patch. Signed-off-by: Scott Seago <sseago at redhat.com> --- src/app/controllers/application.rb | 46 ----------------
2006 Jan 30
2
Modules, controllers and inheritance
Hi! I was trying to cleanup my app and I runned into quite a problem. My controllers in submodule do not seem to inherit things from base class. I have following setup: app/controllers/ application.rb: class ApplicationController admin/ admin_controller.rb: class Admin::AdminController < ApplicationController include LoginEngine include UserEngine
2007 Oct 26
1
Spec custom finders
I have some finders in my models where I write some of the sql myself. I of course want to test these, but am not sure the best way. Should I just let them roll through to the db, and verify they return the correct objects based on the fixtures I load, or should I spec the actual query? I know that DB access is sort of frowned upon, but is this a situation where it is more or less acceptable? My
2008 May 30
6
Session problem
Hello everyone, I am just starting a project for school in RoR and I am a complete n00b ^^ Here''s my problem : I need to get the user''s login stored in the session but for some reason I cannot. Here''s my login method code : def login if request.post? @user = User.find_by_username(params[:login]) if @user and @user.password_is? params[:password]
2006 Mar 08
2
inheritance problem with controllers
i have a controller like this: class SpoilageController < DataEntryController before_filter { check_access_key(''_SP'') } ... and in the parent class is this: class DataEntryController < ApplicationController def check_access_key(key) if !@session[:user].admin && !@session[:user].data_entry_access.to_s.upcase.include?(key) render
2007 Nov 20
3
Plugin: can't call before_filter in ApplicationController
Hi all I want to outsource an extension for ApplicationController, that I had in application.rb so far, into a plugin. I have created this plugin, and in init.rb I load require File.dirname(__FILE__) + ''/lib/application_controller'' In lib/application_controller.rb I have the following code: class ApplicationController before_filter :prepare_user ... end This worked
2013 Mar 20
2
Rspec + Devise + BaseController
Hello there, I''m creating a base controller for the admin section of a project. All controllers whitin the admin section will inherit from it. ##################################################### #app/controllers/admins/base_controller.rb class Admins::BaseController < ApplicationController layout "admin_cms" before_filter :authenticate_admin! end
2006 May 16
2
before_filter and the application controller
Hi there, I''m having a bit of an issue with my before_filter. I know that the filters put in the application.rb controller are global for all the controllers. In my application filter I''d like to allow access to the RSS feed method in a ''member'' controller and skip the login checks that the before_filters are currently performing. In my application my filters
2006 Jan 29
3
SHLG and lib dir
Slowly figuring out how to get my SaltedHashLoginGenerator stuff working. The wiki page says to put "before_filter :login_required" in the user (my "user" is "member") controller or in ApplicationController. However, wherever I put it I get NoMethodError. The rest of the SHLG stuff seems to be working... or at least I could get to the signup page, register, and
2006 Jun 04
5
filter function with parameter
Hi! I want to add a function with a static paramter ("2" in the example) to a filter, but somehow Rails seems to be looking for another syntax. before_filter :check_quantity(2), :only => [:show] doesn''t work. What''s the right way to do this? Thanks a lot! -- Posted via http://www.ruby-forum.com/.
2014 Jul 21
0
Install VMware Workstation
Hie Guys Has anyone managed to run VMware WorkStation 10.0.3 on CentOS 7? Mine ask for some modules to be compiled and loaded into the running Kernel before VMware can run, then an ERROR copy or error below: 2014-07-21T09:01:41.429+02:00| vthread-3| I120: The header path "/lib/modules/3.10.0-123.4.2.el7.x86_64/build/include" for the kernel "3.10.0-123.4.2.el7.x86_64"
2008 Sep 24
3
caches_page :if not executing (but caches_action :if) does
Hi folks - Seeing a weird problem and would love some help. It''s documented in http://pastie.org/278310 to be more readable. In short, I have a caches_page "action", :if => {stuff} but the :if is never being called - the action is just caching every time. (If I put a debugger call in the :if block, it never stops.) If I replace caches_page with caches_action, the if
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
2023 Aug 01
2
Plotting Fitted vs Observed Values in Logistic Regression Model
Dear friends, I hope this email finds you all well. This is the dataset I am working with: dput(random_mod12_data2) structure(list(Index = c(1L, 5L, 11L, 3L, 2L, 8L, 9L, 4L), x = c(5, 13, 25, 9, 7, 19, 21, 11), n = c(500, 500, 500, 500, 500, 500, 500, 500), r = c(100, 211, 391, 147, 122, 310, 343, 176), ratio = c(0.2, 0.422, 0.782, 0.294, 0.244, 0.62, 0.686, 0.352)), row.names = c(NA, -8L),
2006 Jan 11
7
before_filter: how to give :except more than 1 value?
Hi all I have the following class: class MemberController < ApplicationController before_filter :authorize, :except => :index def index ... end Now I want to give the before_filter more than one :except argument. I tried :except => {:index, :login}, but this didn''t work. How can i accomplish this? Thanks a lot and have a nice day, Josh -- Posted via
2010 May 08
2
uninitialized constant - Please Help Me...
Hello everyone, I''ve decided to take the step into creating a mini-forum for my website where users can open new posts on exixting topics and allow people to discuss things etc... I am following a tutorial in the book: APRESS - Practical Rails Social Networking Sites and have hit a minor issue. Part of the Forum requirements is to add a moderator role to allow only certain individuals
2006 Apr 17
2
newbie before_filter question
I''ve successfully gotten acts_as_authenticated working. Currently the before_filter line for my admin screen is like this: class AdminController < ApplicationController include AuthenticatedSystem before_filter :login_required Only issue I have now is that anyone logged in can access that screen. I''d like to differentiate between a regular user and