activemodel Questions

4

Solved

I tried create new model which has auto type casting without table in database. I've tried to inherit from ActiveRecord::Base it's thrown exception ActiveRecord::StatementInvalid: PG::UndefinedTabl...
Westmorland asked 5/1, 2017 at 21:25

1

Solved

I'm using the gem active_model_serializers. Serializers: class ProjectGroupSerializer < ActiveModel::Serializer attributes :id, :name, :description has_many :projects end class ProjectSeria...
Dignify asked 3/2, 2017 at 3:36

5

Solved

How do I get ActiveRecord attributes method functionality? I have this class: class PurchaseForm include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming at...
Chivalry asked 28/3, 2011 at 17:4

1

Solved

I am trying to do some basic rspec testing with shoulda matchers and I've come upon an error I haven't seen asked on SO before. I have a unique attribute called name, but for reasons required of t...
Deathful asked 14/10, 2016 at 22:40

2

I've set up an ActiveModel class in my Rails app like this: class MyThingy extend ActiveModel::Naming extend ActiveModel::Translation include ActiveModel::Validations include ActiveModel::Conv...
Coulomb asked 11/6, 2012 at 6:32

2

Solved

I'm trying to use ActiveModel instead of ActiveRecord for my models because I do not want my models to have anything to do with the database. Below is my model: class User include ActiveModel::...
Marlin asked 17/7, 2011 at 4:38

2

Solved

I'm upgrading a Rails application I've inherited from 3.2 to 4.0.1. I followed and finished the edge guide here: http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#upgrading-from-rail...

3

Solved

According to the ActiveJobs guide, section 8, it says: This works with any class that mixes in GlobalID::Identification, which by default has been mixed into Active Model classes. Mongoid::Do...
Brandwein asked 7/1, 2015 at 13:48

1

I have a Model Action that has a belongs_to :actor, polymorphic: true that actor can be: a Customer, Admin, Seller or Guest. I want to filter instances of Action to just the actions made by a p...
Brittnee asked 26/11, 2015 at 9:3

6

Solved

How can i set include_root_in_json to false for all my RoR models? I've tried to set ActiveModel::Base.include_root_in_json = false inside application.rb, but it has no effect.
Amice asked 10/12, 2010 at 10:44

3

Solved

How to impliment ActiveModel associations (tableless nested models)? For example: book has many chapters With ActiveRecord I would create two models and assosiate them with has_many and belong...
Ninette asked 6/7, 2011 at 8:18

2

Solved

I need to validate email saving in email_list. For validation I have EmailValidator. But I cannot figure out how to use it in pair of validates_each. Are there any other ways to make validations? ...

5

Solved

With the recent upgrade to Rails 4, updating attributes using code resembling the below does not work, I get a ActiveModel::ForbiddenAttributes error: @user.update_attributes(params[:user], :as =&...

3

Solved

Is there anyone who can help me by defining the exact difference between Active Model, Active Record and Active Resource. I have done enough googling in order to find the exact difference, but didn...

2

Solved

I'm working on a small DataMapper-like ODM project, and I'm trying to make use of the ActiveModel::Validations component. However, I ran into a problem while writing tests - I'm using anonymous cla...
Prognosis asked 21/1, 2013 at 2:29

2

Solved

I'm trying to send my front-end application json that looks like this: { facilities: [ {id: 5, name: 'happy days ranch', location: { address: '1424 Pastoral Lane', zipcode: '25245'}, instructor_...

2

Solved

The full error is the following: ActiveModel::ForbiddenAttributesError in Admin::ProductsController#create My product model only has a name and price. Why is commit a parameter? When I click th...
Overbalance asked 20/3, 2014 at 0:27

3

Solved

I have a nested attribute on which I perform presence validation. I am trying without success to provide translations for the attribute name that is returned in the full error message text. The mo...
Jackquelinejackrabbit asked 4/8, 2014 at 11:13

2

Is possible use ActiveModel without rails?. Is possible use ActiveModel in desktop application?
Chigoe asked 6/12, 2010 at 1:43

0

I am working on a small Rails project that simply allows a user to submit a form and the information from the form is sent via an API call to another service for consumption. Here is my model: cl...
Mitchum asked 21/7, 2014 at 13:53

1

Solved

I have the following models: class Programme < ActiveRecord::Base has_and_belongs_to_many :nationalities, class_name: 'Nation', join_table: 'nationalities_nations' has_and_belongs_to_many :d...
Leucoplast asked 22/5, 2014 at 16:39

3

Solved

How do I serialize permissions with active_model_serializers? I don't have access to current_user or the can? method in models and serializers.

6

Solved

I've configured my database.yml to point to my existing mysql database how can I generate models from it? rails generate model existing_table_name only gives an emty model..
Smythe asked 7/11, 2010 at 20:58

1

Solved

We are trying to add multiple favoritable objects, where a user can favorite many different objects, but are not sure how to make it work. Here is the Favorite model: class Favorite < ActiveR...

3

Solved

I want to DRY up several models by moving shared scopes into a module, something like: module CommonScopes extend ActiveSupport::Concern module ClassMethods scope :ordered_for_display, order(&q...
Scott asked 6/9, 2011 at 17:31

© 2022 - 2024 — McMap. All rights reserved.