Displaying 5 results from an estimated 5 matches for "_attributes".
Did you mean:
attributes
2008 Jan 11
5
Missing methods
We have a custom implementation of the Mother Object idea. It''s inside
of a module, basically like this:
module Factory
%w(account friendship person invitation message asset email_address
birth).each do |klass|
eval <<-EOF
def self.create_#{klass}(attributes = {})
default_attributes = valid_#{klass}_attributes
#{klass.camelize}.create! default_attributes.merge(attributes)
end
EOF
end
def valid_message_attributes(options = {})
{
#some message options
}
end
#more valid_x_attributes methods
end
When I require this file in a spec file, Factory.create_person wor...
2005 Dec 15
3
Generic Question about the way code is written
Hi,
This is a generic question about the way code is written in prototype and scriptaculous libraries.
Inside every object, we find functions that begin with "_".
How are these methods/functions different from the rest?
eg _text, _attributes, _each...
Please let me know.
Thank you,
Mandy.
2006 Apr 16
8
"Cannot convert String to Integer" after using association
So, I''ve written a partial that does some stuff with a given instance of
my class "entity". Entity is ActiveRecord. I''m able to retrieve all
sorts of data from an @entity, until I do something like:
<% for @attribute in @entity.attributes %>
<div id="attribute_<%= @attribute.id %>">
<%= render(:partial =>
2011 Feb 11
1
accept_nested_attributes, reject_if doesn't work.
class Post < ActiveRecord::Base
validates :name, :presence => true
validates :title, :presence => true,
:length => { :minimum => 5 }
has_many :comments, :dependent => :destroy
has_many :tags
accepts_nested_attributes_for :tags, :allow_destroy => :true,
:reject_if => proc { |attrs| attrs.all? { |k, v| v.blank? or v.nil? } }
end
rails c
irb(main):001:0> post=Post.first
=> #<Post id: 1, name: "prova", title: "titolo prova", content: "prova
1", created_at: "20...
2012 Sep 18
4
"best practices" for Rails serving RESTful JSON services for use by AngularJS, Ember.js, etc.
...You need to be able to transactionally make alterations to associations
and collections of associations, not just to a single resource.
* The services also should make it as easy as possible to integrate with
these frameworks. To persist an associated model you shouldn''t have to tack
on _attributes to the key in the JSON because odds are that the Javascript
app is just storing it as whatever the association name is, or perhaps some
other name that makes more sense. You should be able to send in the JSON
assocation data for something and the controller should know via mass
assignment secur...