similar to: calculate method is gone once I use ''find''?

Displaying 20 results from an estimated 9000 matches similar to: "calculate method is gone once I use ''find''?"

2006 Mar 02
3
Modifying "Find" to always add a condition?
I''d like to always add a condition to any version of "find" (e.g. Thing.find(), Thing.find_by_name(), Thing.find_by_whatever) so that in addition to whatever conditions are set, an additional condition is set :conditions=>"user_id=#{current_user.id}" I''d like to make sure that a user only sees/edits/creates entries in the database that have the user_id
2006 Aug 15
2
Working with user data
I am a Rails newbie and I am trying to build a test site in which users will have their own sets of data. I understand how to manipulate shared data very well. Most of the Rails examples out there seem to deal with such shared data. I am struggling with the "best practice" method for a user to work with their own data however (and not be able to view/edit other users''
2006 Apr 24
5
Custom pagination
I am trying to paginate objects from a has_many/:through relationship using Paginator. current_user.things returns the objects that I''d like to paginate. For testing, I tried to make it 1 item per page. I initialise the paginator as follows: @thing_pages = Paginator.new(self, current_user.things.count, 1, @params[''page'']) I don''t know how to obtain
2006 Jul 27
2
Creating multiple objects from form data
I''m in the process of creating a sign up form for an online application. The form collects account info, company info, and then info for an administrative user. The method looks like this: def create @account = Account.create!(params[:account]) @company = @account.companies.create!(params[:company]) @user = @company.users.create!(params[:user]) end However, this inevitably fails
2008 Jan 30
2
Where can I get "authenticate_with_http_basic"?
Hi, I just installed Rails 2.0.2 [root@mymachine easyx]# ruby --version ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux] [root@mymachine easyrx]# gem install rails --include-dependencies Need to update 16 gems from http://gems.rubyforge.org ................ complete Successfully installed rails-2.0.2 [root@remandev easyrx]# But I''m getting this error in my restful_authentication
2010 Sep 03
1
Action Controller Error: undefined local variable or method `current_user'
Newbie learning Rails. I''m currently on Chp9 here: http://railstutorial.org/chapters/sign-in-sign-out#top At the end of the tutorial, rails is erroring (see below). being new to Rails and after having checked the tutorial... How do you resolve this kind of error. It''s saying current_user is not defined, and it is supposed to be defined with/Sites/sample_app/app/helpers/
2006 Nov 01
17
So how can I rewrite my app without using with_scope?
So, I hear that with_scope is going to be deprecated. Which is a bit of a shame, given the stuff I''ve been writing recently. I have a CMS with multiple clients. A ''client'' is essentially a company, with multiple users. Content on the site belongs to a client - content could be messages, images, schedules, etc etc. People belonging to one client should not be able
2009 Sep 16
5
piece of code that runs only once
hi, an strange error is happening here in User model i have the following method: def falta_votar Category.find(:all) - votes.collect {|v| v.category} end and in the default.html.erb layout i have: <%= current_user.falta_votar.size %> but it only works once, when i try to access another page i get an error message saying that the falta_votar method is nil, then i have to restart
2012 Mar 09
2
ActionMailer message delivery content
I have the ability to send email to a user if a certain user has requested interest in their product. In my email I want to include certain information that is pulled from users but at the moment I am getting errors because it states that they are undefined despite these lines being used elsewhere in my application. I shall copy the email below and anything between the <% %> is what I wish
2010 Jul 28
1
paperclip, authlogic and callback issue
I use authlogic for authentication and paperclip for handling user''s profile picture attachments. I use the following method to get the current_user def current_user_session return @current_user_session if defined? (@current_user_session) @current_user_session = UserSession.find end def current_user return @current_user if defined?(@current_user)
2010 Apr 16
4
DEEEEPLY nested
Hello, i have "a" has many "b", "b" has many "c", and "c" has many "d" Now... "d" is a user model, and I have a current_user helper method defined. If i navigate to an "a" show page, how can I make sure that my current_user ("d") is part of that "a"? meaning how can i make sure that
2006 Oct 09
5
Problem setting variables in ApplicationController.
I''m dynamically generating menu options based on the currently logged in user: current_user. My menus are setup on the applicatin.rhtml file. The current_user is defined in the application controller. But, attempting to assign it a value while in the application controller results in an ''undefined method'' error. ApplicationController .... def current_user @cu =
2006 Jan 16
16
acts_as_authenticated current_user in a model?
What do I need to do to be able to use an acts_as_authenticated current_user in a model? Is there some sort of include or require I can do some where that would allow this? ********************************************************** Here is what I am trying to do: ********************************************************** class Setting < ActiveRecord::Base before_create :created_by_user #
2009 Oct 28
1
Authlogic Page View Authentication Help
Hi: I am a newbie at ROR, and I am grasping my head around Authlogic. I am having hard time trying to figure out how can I do the following: in my application controller I have the following helpers: filter_parameter_logging :password, :password confirmattion helper_method :all private def current_user_session return @current_user_session if defined? (@current_user_session)
2002 Jun 03
1
What is so bad about primaryGroupID=513?
I try to set up Samba 2.2.4 / LDAP as a PDC and it almost works. The only thing I don't understand is why a domain user can't have a primaryGroupID of 513 (which looks like it should be a safe default). But if I set it, login is denied with an error C0000078 on the client, and something like [2002/06/03 10:32:28, 3] smbd/sec_ctx.c:set_sec_ctx(314) setting sec ctx (65534, 65534) -
2007 Aug 21
2
using restful_authentication current_user inside controller specs
I''m using restful_authentication in my app and I have the before filters in my application rhtml: before_filter :login_required around_filter :set_timezone around_filter :catch_errors Currently I have them commented out while rspec''in but I''ll need to add them in my specs. def create @ticket = Ticket.new(params[:ticket]) @ticket.user = current_user if
2007 May 17
4
How to mock helpers in view specs ?
Hi all, I am mocking the following Rails view (inside a partial): <%= render :partial => "forums/forum", :collection => forum_category.forums.readable_by(current_user? ? current_user : nil) %> My spec fails with the following message: 1) ActionView::TemplateError in ''forum_categories/index (anonymous user) should only render forums accessible to anonymous
2011 Feb 05
4
Questions about Chapter 9: Sign in, Sign out of RoR Tutorial | Learn Rails by Example
Hello Finished reading chapter 9 and im a little bit confused. 1. In the tutorial, Modules are used instead of creating a Model and working in a class inside a module , like in authenticating passwords. Wouldn''t that be possible? Or is it unnecessary since we''re not messing with a database in terms of storing data? 2. what is the difference between session[:remember_token] =
2007 Aug 23
3
recording current_user
Hi, Another noob here I am afraid! I have a questuin about the current_user method that comes with AAA. I have AAA set up and working fine and if i put <%= self.current_user.login %> into a view it shows the login name as expected on the page. What I cant work out is how to record this into the database when the user completes a form. My app so far only has two models.
2008 May 06
1
check_friendship method only returning value of last pair
Hello, I''m new to facebooker and ruby, so not sure if the issue I am having is due to my misunderstanding or a bug in facebooker plugin. Here is what I have: def show @current_user ||= facebook_session.user @member ||= params[:id].to_s==@current_user.id.to_s ? @current_user : Facebooker::User.new(params[:id]) #for each of current_user''s friends, check if they are