similar to: how to control self.method access

Displaying 20 results from an estimated 600 matches similar to: "how to control self.method access"

2006 Feb 15
8
Agile book - getting confusing error
Working through the beginning phase from the Agile book on ''Administration'' undefined method `hashed_password='' for #<User:0xb7911324> ... /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing'' #{RAILS_ROOT}/app/models/user.rb:12:in `before_create''
2006 Apr 03
7
Getters and setters problem?
Hi list, first evening of playing with rails, so please forgive me if I ask something stupid. ;-) I created a User model and tried to use ActiveRecord callbacks to convert the password to sha1 just before saving it. For some reason postgresql gives me a error because the given password is null. To test even further I tried to change :login too, same error happens, :login is empty too. I am sure
2006 Aug 07
2
NoMethod Error: Modifying Location of support modules
I''m trying to follow along with the Agile Development with Ruby on Rails book and have encountered a problem with code having the following syntax (partial class provided): require "digest/sha1" class User < ActiveRecord::Base private def self.hash_password(password) Digest:SHA1.hexdigest(password) end end I''m getting an error as: undefined method
2006 Jun 05
2
When adding a record in console, a parameter comes in as null even when I set it
In console, I am trying to create a User but the :account_id does not come in. Console just gives me back :account_id => nil. Obviously I''m trying to set it though. Silly console... But, I can set the account_id column in my controller like so: @user = User.new(params[:user]) @user.account_id = account.id @user.save Here''s what I give to the controller: User.create :name
2006 Apr 28
7
a simple problem but difficult
how can i access to a collection that was created in the same control and the data that a want to access isn?t the id the collection has : id, usuario, comandancia comandancia is the data to access the question is how to access comandancia in @acceso this code is wrong : def new @catelemento = Catelemento.new @acceso= Catacceso.find(:all, :conditions
2006 Jan 16
4
Question about self and private
Hi! There''s something I don''t understand yet about static/private methods. I hope someone can explain... E.g.: class SayHello def hello(who) puts "Hello, " + who + "!" end def self.say(words) puts words end end hello = SayHello.new hello.hello "World" : Hello World! hello.say "hi" : Error SayHello.say
2007 Dec 31
1
Agile Web Dev w/Rails - Password Change
Happy New Year everyone. Just wondering if anyone has coded the ability to allow a user to change their password following the way the book (second edition) implements administration. Seems like I should be able to cut out the password/password_confirmation portion of ''add_user'' form to create a ''change_pass'' form. The problem is I''m not sure how to go
2005 Dec 17
1
lost in an ActiveRecord::StatementInvalid
I have an error I don''t know how to debug. I am adding the login suport in Depot (the example in the RoR book) and LoginController#add_user throws ActiveRecord::StatementInvalid in an innocent /login/add_user GET request. The trace goes down to a call to SQLiteAdapter#table_structure, and the source code suggests what''s happening is that "PRAGMA
2005 Apr 23
7
Validation question
Hi all, Is there a way to invoke validations at times other than save, create and update? I know that I can do this by writing my own validation checks using errors.add_[blah], but I''d like to leverage the existing validation code. What I have is two sets of fields in a record, set A and set B. Both sets must be validated on record create. However, the trouble is that after
2006 Aug 14
2
Change password
Is there an addition to the Rails Recipe or the method in AWDWR to allow a user to change his/ her password? I have put something together that does all the work again - mostly because I''m not sure how to leverage on methods like ''password='' that are defined in the model. Has anyone got a ready sample that I could learn from? Right now, I''m basically
2006 Mar 13
7
Problem with params
I''ve got a User model, which holds the following (excerpt): def try_to_authenticate User.authenticate(self.username, self.password) end .. private def self.hash_password(password) Digest::SHA1.hexdigest(password) end def self.authenticate(username, password) @user = User.find(:all, :conditions => ["username = ? AND password = ?",
2010 Mar 01
3
Closing loop: How-to for NVIDIA driver on Xen Dom0
I had a couple comments on my proposal to write a how-to on NVIDIA on Xen Dom0: Marcus: I would rather prefer if you could take care of the current Xen articles on the wiki, first. They are quite outdated. --- I don't consider myself an expert on all things Xen. In reviewing the material on the CentOS Wiki regarding Xen, I felt the articles were pretty well done (even if they were
2006 Jan 30
2
problem redefining module method
I''m having a problem redefining a method in one of my modules. Lets say I have this module in /lib: module Hello def say_hello "hello" end end And one of my ActiveRecord models mixes it in like: class Item < ActiveRecord::Base include Hello end This works fine, I can call @item.say_hello just fine. But when I try to redefine the method: class Item <
2006 Jul 17
19
updating model
hello, i am writing a simple user login system. when registering a user account, i have two field: password password_confirmation which are validated using validates_presence_of validates_confirmation_of and these are then used to generate a password hash which is stored in my database when i want to update the record (without changing the password and entering new values for password and
2006 Oct 01
9
How to create a very simple form
Hi all, I would like to create a very simple form with RoR similar to this one in ASP.Net: http://quickstarts.asp.net/QuickStartv20/aspnet/samples/ctrlref/standard/TextBox/TextBox1_vb.aspx I my RoR project I want to add a Greeter class like this one: class Greeter def initialize(name = "World") @name = name end def say_hi puts "Hi #{@name}!" end def
2009 Jul 28
4
RJS-Template and link_to_remote
Hi, I am quite new to rails and can''t use any rjs-templates. The problem is, that he can''t use/find the methods in that template e.g. ''page'' or ''replace_html''. I get an error message on these methods. Here''s what I got so far in my example: Controller: ---- class AjaxTestController < ApplicationController layout
2006 Jul 20
5
RJS where to put helper method?
Hi, If I want to have helper method for my rjs, where''s the best place to put it? so for example: --- bla.rjs: page.replace_html ... page.visual_effect ... --- somewhere: (currently I put in application_helper.rb) def replace_with_effect(page) page.replace_html ... page.visual_effect ... end --- bla.rjs: replace_with_effect page and is there a way to define the helper so we
2010 Feb 11
2
LinkingTo and C++
Hello, I've been trying to make LinkingTo work when the package linked to has c++ code. I've put dumb packages to illustrate this emails here ; http://addictedtor.free.fr/misc/linkingto Package A defines this C++ class: class A { public: A() ; ~A() ; SEXP hello() ; } ; Package B has this function : SEXP say_hello(){ A a ; return a.hello() ; } headers of package A are copied
2008 Apr 04
5
First call to worker method doesn''t work
I have a worker as follows: class SampleWorker < BackgrounDRb::MetaWorker set_worker_name :sample_worker def create(args = nil) # this method is called, when worker is loaded for the first time end def my_method # Deliver test e-mail message Notifications.deliver_message(1, "DM") end end I have a rails controller that calls the following code: worker =
2007 May 10
13
Is there a way to do incremental search?
Say the user first enters "ruby" for search and gets 1000 results. Then he can search "rails" just in the 1000 results just returned. The common scenario is some kind of advanced search. User can incrementally add criteria and the program will narrow the results step by step. I know that at least I can use all the criteria as a whole to do the searching, but this is a waste