rails-models Questions

2

Solved

I am trying to save a boolean value in a model by seeding it 20151130014042_create_duty_statuses.rb class CreateDutyStatuses < ActiveRecord::Migration def change create_table :duty_statuses, :...

3

Solved

I'm developing a Rails Engine (Plugin). So far I have Set up RSpec as a framework Added a migration to create a model/table called MyJob Added some basic model tests under spec/models/my_job_spe...

4

Solved

In my app; when I submit form, I get this error: LoadError at /questions Unable to autoload constant Message, expected /app/models/message.rb to define it It points to the create action in the ...
Dissimilar asked 20/6, 2014 at 16:35

2

Solved

I'm running Rails 5.1.4, and I have a model that looks like this: class Quota < ActiveRecord::Base belongs_to :domain, optional: true belongs_to :project, optional: true end A quota should ...
Sororicide asked 11/12, 2017 at 23:35

5

So I have a method on my model object which creates a unique sequence number when a binary field in the row is updated from null to true. Its implemented like this: class AnswerHeader < Applica...
Renferd asked 29/9, 2017 at 17:17

3

Solved

I have a Sponsors model and a Promo Codes model. A sponsor can have zero or more promo codes A promo code can have zero or one sponsors Thus a promo code should have an optional reference to a ...
Berretta asked 24/2, 2014 at 16:48

6

I am currently working on a Rails 3 project that is divided up into four parts: The public facing website The administration website/backend The models The API for third party data access As th...
Vladimir asked 11/8, 2011 at 11:5

3

Solved

I have a User model. I can check whether a User is an admin by doing a_user.try(:admin?). I'd like to define a named scope that gets all Users updated within the last X minutes who are not admins....
Naga asked 31/1, 2013 at 10:33

2

Solved

I have a model & a table which I no longer need in my App, I could leave them there but I would like to remove them to keep things tidy. I'm trying to figure out the best way to remove them wit...
Blanchette asked 26/3, 2013 at 22:5

6

Solved

For a Rails 3.0 Todo app, I have a Tasks model with a Status field. What's the best way to store the Status field data (field type) and still display a human-readable version in a view (HTML table)...
Metaprotein asked 16/4, 2010 at 5:49

2

Solved

So, I am working on migrating this php site with an existing database which I cannot change over to Rails. There is a table: Quotes with a column named type. Whenever I try and create a model of th...
Biramous asked 14/8, 2013 at 22:27

1

Solved

I have two models, Complaint and Company. Complaint belongs_to and accepts_nested_attributes for Company, and Company has_many Complaints. # Models class Complaint < ActiveRecord::Base attr_a...
Unbounded asked 18/3, 2013 at 6:46

3

Solved

In a Rails application, how can I migrate the changes I make in models? For instance, I know that if I create a model with command rails g model Person name:string, a migration will be created as w...

4

Solved

I want to have a "Customer" Model with a normal primary key and another column to store a custom "Customer Number". In addition, I want the db to handle default Customer Numbers. I think, defining ...

2

Solved

Say I have a model of type A, and a model of type B, which has the fields a_id a2_id. I want to have something like: class B belongs_to :a belongs_to :a (using a2) end Does anyone know how I w...
Masoretic asked 24/7, 2012 at 0:13

5

Solved

This is a newbie question, but I'm still learning how to create an association between two models in rails. I have a user model and a journal_entry model. The journal entries belong to the user and...
Encompass asked 6/7, 2012 at 1:26

1

Solved

I had a discussion recently with a friend of mine who is also a RoR developer. We argued about how Rails models should be managed. Personally I like to leave in the default namespace only the root ...
Musa asked 28/3, 2012 at 18:30

2

say, if we generated a model rails generate model animal name:string birthday:date and now we want to create other model to inherit from it (such as Dog and Cat), should we use rails generate mo...

3

Solved

Rails has a has_one :through association that helps set up a one-to-one association with a third model by going through a second model. What is the real use of that besides making a shortcut associ...

3

Solved

I a little confused about how this work even if it works properly. I have a model that has two association to the same other model. Company has an owner and company has many employees of the clas...
Farthest asked 26/9, 2009 at 7:2
1

© 2022 - 2024 — McMap. All rights reserved.