activemodel Questions
1
Solved
I've been using plain Ruby form objects in rails, but to keep my code organized, I've ended up having to add a ton of namespaces to them. So I'll have a form like:
class User::Registration::NewFor...
Unblinking asked 31/10, 2013 at 1:22
2
Solved
I've got three models. Sales, items, and images. I'd like to validate that when a sale is created there are at least three photos per sale and one or more items. What would be the best way to achie...
Snead asked 29/3, 2012 at 19:50
3
I have the following code, which works fine with no errors but the models never get saved...
myarray.each do |item|
r = MyModel.unscoped.where(:site_id => @site.id, :url => item['permalink...
Topless asked 23/8, 2013 at 17:42
3
Solved
I have some problems with one of gem supporting ActiveModel caching. When I'm using observer for cached model, during application initialization it tries to describe table to get all fields names. ...
Christy asked 30/5, 2012 at 9:53
2
Solved
In Bryan Helmkamp's excellent blog post called "7 Patterns to Refactor Fat ActiveRecord Models", he mentions using Form Objects to abstract away multi-layer forms and stop using accepts_nested_attr...
Faddist asked 3/2, 2013 at 7:32
2
In my Rails 3.2.11 and "development" environment when I try to have an active model:
class DisponibilityApi
include ActiveModel::Model
attr_accessor :start_time, :end_time
validates :start_ti...
Smithereens asked 6/2, 2013 at 19:34
1
Solved
When using autocomplete in the console, I often see "_was" postpended to my attributes. But I can't find any documentation or best practices for usage. What does it do and how should it be used?
E...
Eighty asked 16/12, 2012 at 23:43
2
I have a callback of a model that needs to create a dependent object based on another field entered in the form. But params is undefined in the callback method. Is there another way to access it? W...
Rosenblum asked 28/11, 2012 at 19:25
1
Solved
I have a very generic validator and I want to pass it arguments.
Here is an example model:
class User
include Mongoid::Document
field :order_type
has_many :orders, inverse_of :user
validate...
Anders asked 24/10, 2012 at 1:59
2
Solved
Using the ActiveAttr:
class Filter
include ActiveAttr::Model
attribute term
# Overriding to_key, to_param, model_name, param_key etc doesn't help :(
end
class SpecialFilter < Filter
end
H...
Remington asked 7/9, 2012 at 7:1
1
Solved
Summary: I'm trying to alter an attribute's value within a custom ActiveModel::EachValidator validator. Given the following prototype:
def validate_each(record, attribute, value)
trying to set va...
Grieve asked 30/7, 2012 at 18:15
2
Solved
As a preface to this question: I am brand new to Rails development (and web-development in general), and some of my concerns may be unfounded, so any feedback would be very helpful.
I am attemptin...
Topeka asked 15/6, 2012 at 23:50
7
I have some troubles with rails 3.2.0 & ruby 1.9.3, I only created a new app with rails new command and I'm trying to deploy to heroku. I'm having the following app error:
An error occurred in ...
Jonniejonny asked 21/1, 2012 at 13:27
1
Should I extend or include ActiveModel:Validations:Callbacks:ClassMethods or ActiveModel:Validations:Callbacks?
Recompense asked 20/1, 2012 at 4:55
1
I am trying to get ActiveModel::Callbacks to work with ActiveResource (specifically after_initialize) for a Rails 3 app, but I can't seem to get it to work. I don't get any errors, but the callback...
Parodic asked 14/2, 2012 at 0:12
1
Solved
I want to ensure users can't create usernames that clash with my existing routes. I would also like the ability to deny future routes I may define. I am thinking of accomplishing this like so:
In ...
Newel asked 2/1, 2012 at 23:20
1
Solved
I am wondering how to do the association in Rails correct. First I create a City model and an Organisation. Now I want to have an Organisation have a City... this is done by adding the has_many and...
Betake asked 14/11, 2011 at 14:3
1
Solved
I would like to have a Dashboard to display summary of multiple models, and I implemented it using Presenter without its own data. I use an ActiveModel class (without data table):
class Dashboard
...
Melodist asked 24/9, 2011 at 5:12
2
Solved
With a regular ActiveRecord/SQL setup in Rails, in console when I execute commands *.where, *.all etc., I get back the actual array of record items. However, after switching to Mongoid, I instead g...
Dhumma asked 7/7, 2011 at 6:56
2
Solved
I use Rails 3.0.4 and RSpec 2.5. In my controllers I use named scopes heavily, for example
@collection = GuestbookEntry.nonreplies.bydate.inclusive.paginate(
:page => params[:page], :conditions...
Borgeson asked 9/3, 2011 at 20:8
3
Solved
I try to follow http://api.rubyonrails.org/classes/ActiveModel/Validator.html , but where should I put the
class MyValidator < ActiveModel::Validator
def validate(record)
if some_complex_lo...
Theodoretheodoric asked 17/12, 2010 at 7:53
1
Solved
Where are the default validation error messages in Rails 3.0? What is the equivalent of ActiveRecord::Error.default_error_messages[:taken], for example? I have gotten as far as finding that ActiveM...
Camphorate asked 27/9, 2010 at 22:23
© 2022 - 2024 — McMap. All rights reserved.