similar to: mattr_accessor inside a class

Displaying 20 results from an estimated 2000 matches similar to: "mattr_accessor inside a class"

2011 Jul 30
22
Question about Helpers
Studying the RoR 3 Tutorial book by Michael Hartl and on page 345 there''s the code inside the SessionsHelper: _________________________________________________________ module SessionsHelper def sign_in(user) cookies.permanent.signed[:remember_token] = [user.id, user.sault] self.current_user = user end end __________________________________________________________ What is the purpose
2011 Sep 20
0
What's the difference between mattr_accessor and cattr_accessor in ActiveSupport?
Hi, I was reading source code of mattr_accessor and cattr_accessor in ActiveSupport and found out that the method definitions are all most identical. Except cattr_writer accepts a optional block. I googled and read http://stackoverflow.com/questions/2203800/difference-between-mattr-accessor-and-cattr-accessor-in-activesupport. That guy had the same question as me, but no one answered the question
2012 Sep 11
1
define_method vs module_eval
Rails code: Accessors.send :define_method, :"default_#{name}", &block Accessors.module_eval <<-METHOD, __FILE__, __LINE__ + 1    def #{name}    -ISKimRw02aC5oVgD8gxYQQ@public.gmane.org(:#{name}, [])    end    def #{name}=(value)    value = value.present? ? Array(value) : default_#{name}    _set_detail(:#{name}, value) if value != @details[:#{name}]    end  
2006 Jul 13
4
Does text_field go directly to attributes hash in AR object?
All, I''m having a hell of a time figuring out what is going on here. I''m trying to override one of my getters so that I can format it a certain way in my form. But I can''t seem to get text_field to call the appropriate method on my object. So here''s my getter: public def FAX fax = read_attribute(:FAX) puts fax
2014 Mar 04
2
[LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)
On Mar 3, 2014, at 10:29 AM, Chandler Carruth <chandlerc at google.com> wrote: > > On Mon, Mar 3, 2014 at 9:48 AM, Chris Lattner <sabre at nondot.org> wrote: >> In the best case 'get' doesn't really add any meaning, and in the worst case it is actively misleading > > It's getting the range though, just like Function::getArgumentList() returns the
2008 May 18
4
[LLVMdev] Opaque type usage to represent foreign types
In my project I have a group of foreign types (C++ classes) that I want to use, but don't want to represent as structs within LLVM. For example, for each field in each C++ class I have a setter and getter function that I'd like to use. The setters and getters are "extern C" functions to avoid problems with C++'s name mangling. After going over the documentation it
2010 Apr 18
1
Getter and Setter with non DB property
Hi, I can''t find how do i created a getter and setter property for a non db property. what i have done isnt working, i have a cnt mass assign error. Here is what i''ve done: attr_accessor :creator_is_participant def creator_is_participant @participe end def creator_is_participant=(participe) if participe == true @participe = true else @participe
2006 Jun 04
1
Problem with instance variables
Im developing a User model for my application (newbie stuff, but I have to start somewhere). I followed the tutorial at http://sonjayatandon.com/05-2006/how-to-build-a-secured-web-application-with-ruby-on-rails/ and decided to add an email field. The problem is that the email is not being saved on the database and I end up with two email variables: @email and email. validates_presence_of
2007 May 04
5
[ win32utils-Bugs-10589 ] Bug in win32-mmap
Bugs item #10589, was opened at 2007-05-04 12:01 You can respond by visiting: http://rubyforge.org/tracker/?func=detail&atid=411&aid=10589&group_id=85 Category: win32-mmap Group: Code Status: Open Resolution: None Priority: 3 Submitted By: Daniel Berger (djberg96) Assigned to: Daniel Berger (djberg96) Summary: Bug in win32-mmap Initial Comment: Ruby 1.8.6 win32-mmap 0.2.1 Assigning
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
2012 Sep 22
4
Class, Module, Object
>> reload! Reloading... => true >> puts Class < Module true => nil >> puts Module < Class false => nil >> puts Module < Object true => nil >> puts Object < Module false => nil >> Object.parent => Object The above indicates that the Class object instance inherits from the Module object instance and the Module object instance
2010 Jul 04
2
Rendering a different format in the implementation of a renderer
Yehuda has a nice article on implementing a custom renderer for PDF at http://www.engineyard.com/blog/2010/render-options-in-rails-3/ I''ve tried to follow the example and I''m not sure I see how to get it to work. If I understand things correctly, the format(s) usable in this render call respond_with(@resource) do |format| format.xyz { render :xyz => ... } end
2010 Dec 21
5
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
Hey all, I know that this: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id means that I have an instance variable that has not been initialized. However, I''m a little confused as to what to do in a signup form for form_for: <% content_for :login do %> <% form_for @user, :url => { :action => "login" } do
2006 Jun 07
2
Problem with a setter that converts euros to cents
Hi, I have some problems with an application where I''m using custom accessors to do currency conversions. In my model, I have a price attribute in the database that stores the value in cents, to avoid future problems with float arithmetic and round. But at the views, I would like to show the price in euros, with decimal for the cents. So I defined a new attribute called price_in_euros,
2007 Dec 16
4
Make AR setter methods private?
Hi, I have a AR model that I want to limit changes to be only via instance methods that I''ve added. How do I prevent my other sw from setting the instance''s attributes? I know about #attr_protected and #attr_readonly. But the first leaves the individual setters as they were and the second stops all changes. I want something like "attr_private" Thoughts? Thanks,
2006 Jun 01
1
Automatted Getter/Setter
Hey.. So I have a model that has a lot of number fields. Each of these go through a process when read in and read out to add/remove commas (between every three numbers) to make them more readable. The getter I currently have is like this: def sale_price Listing.insert_commas(read_attribte (:sale_price)) end and the setter is: def sale_price=(price) write_attribute(:saleprice,
2005 Nov 30
3
Downcasing Legacy Table Column Names
I''m looking for the simplest way to *automatically* downcase the attribute names of Models mapped to legacy tables that use upper case. eg: class Workorder < ActiveRecord::Base set_table_name "WORKORDER" end which has "NAME" as an attribute can use "name" as an attribute. currently: workorder = Workorder.find(1) workorder.NAME # =>
2017 Mar 16
3
Re: [RFC] per-device metadata
On Thu, Mar 16, 2017 at 01:46:38PM +0100, Peter Krempa wrote: > > For techincal discussions on design it's better to post to the > development list. > > On Mon, Feb 27, 2017 at 16:41:28 +0100, Francesco Romani wrote: > > Hi, > > Hi, > > > > > > > Currently libvirt supports metadata in the domain XML. This is very > > convenient for
2014 Mar 03
3
[LLVMdev] [cfe-dev] C++11 reverse iterators (was C++11 is here)
On Mar 3, 2014, at 12:04 AM, Chandler Carruth <chandlerc at google.com> wrote: >> I was actually going to check in this, but I can post it for review if folks are worried. >> >> My plan was to provide an implementation of std::iterator_range<T> and then provide 'F.arguments()' which returns it. > > Nice. What's the logic behind .arguments() vs
2008 Apr 25
3
[ANNOUNCE] Samba 3.2.0pre3
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Release Announcements ===================== This is the third preview release of Samba 3.2.0. This is *not* intended for production environments and is designed for testing purposes only. Please report any defects via the Samba bug reporting system at https://bugzilla.samba.org/. Please be aware that Samba is now distributed under the version 3 of