Tagged Questions
2
votes
0answers
258 views
Trouble on saving nested models
I am using Ruby on Rails 3.0.7 and I am trying to save an "has_many :through => checkboxes" class object (I have read the Quick Tip: has_many :through => checkboxes blog post) but I have some ...
1
vote
0answers
49 views
Find Or Create Rails Nested Attribute By Name
I have a Model called Example that accepts_nested_attributes_for NestedExample.
When I create a new Example Model I can also create NestedExamples:
params = { :name => 'Example 1', ...
1
vote
0answers
74 views
How can I set the belongs_to association of a new object via a dropdown menu in the form?
So I'm new to Rails, and I've just finished going through Michael's Hartl's railstutorial.org.
I'm now building my first app, and i'm encountering my first road block.
So basically i've got Bubbles ...
1
vote
0answers
48 views
with_options not working in RoR3 model
Can someone please explain to me why it seems to ignore the with_options block in this code?
class User < ActiveRecord::Base
attr_accessible ...
1
vote
0answers
95 views
rails before_destroy partial delete
I'm trying to figure out a way to partially delete/destroy dependent models in rails.
Code looks something like this:
class User < ActiveRecord::Base
has_many :subscriptions
has_many ...
1
vote
0answers
117 views
Rails: Accessing one model from another model when using Whenever
Currently I have this in my schedule.rb:
every 1.minutes do
runner "Cronjob.cronjob"
end
set :output, File.join(path, 'log', 'cron.log')
and in my Cronjob model:
class Cronjob
def ...
1
vote
0answers
80 views
Validate many objects at the same time
Let's say I have a model called SchoolYear. This model has many periods. When I want create an evaluation structure, it automatically creates three periods with default values.
class SchoolYear < ...
1
vote
0answers
337 views
Rails3 & Globalize3 custom translation model
i'm using globalize3 in a rails3 app. I have a model called Book with some attributes to be translated, all working great. I'm trying to write a before_save function to validate changes in the ...
1
vote
0answers
219 views
Rails model find_or_create
I have this model:
class Profile < ActiveRecord::Base
has_many :skilldetails
has_many :skills, :through=>:skilldetails
accepts_nested_attributes_for :skills, :allow_destroy=>true, ...
1
vote
0answers
20 views
Trying for a special Active Record Model which works as a unique WORM registry
I am trying to create a Model of a pretty special kind.
I just call it Emails. Containing fields like:
address
send_count
blocked
It is a registry of email addresses. Every record in other ...
1
vote
0answers
544 views
Ruby on Rails 3: How to access current_user within model
I have an Activities model that acts as sort of a dashboard for the entire rails app I have. I have some :after_create callbacks passing the Customer object and a generic message into the Activity ...
0
votes
0answers
21 views
Model association dependent by type
Let's say we have a Certificate model with a type(:string) attribute. Depending of the type value, Certificate could have only one instance of three Models(VehicleCertificate, HealthCertificate and ...
0
votes
0answers
31 views
Rails: Custom Model Validation
Hi I am trying to write a custom validation for a model that does not allow the model to be saved if it fails the validation.
Here is what I have so far:
validate :valid_est_time
private
def ...
0
votes
0answers
16 views
Modeling data for relationships/logs versus data templates
I frequently have a situation in which I want to use rows from one model as templates for adding rows to another model.
For example, I have an Invoice model to which I'd like to be able to add ...
0
votes
0answers
47 views
Strange behaviour in Rails MiniTest unit testing of a model
I encounter a very strange behaviour in Rails using MiniTest for unit testing a simple model.
That is my Currency model:
class Currency < ActiveRecord::Base
attr_accessible :currency_cd, ...