cat = Cat.create(name: 'lorem')
cat.cat_color = CatColor.new(name: 'Red')
cat.save!I would like to have cat_color instance automatically saved (after validation). How to achieve this?
| new_article.comments << (comments + article_to_merge.comments).map do |comment| | |
| comment.article = new_article | |
| comment | |
| end | |
| article_to_merge.destroy | |
| destroy |
| class BillingController < ApplicationController | |
| def index | |
| # NOTHING MUAHAHAAHAHAHAHAHHAHAA A | |
| end | |
| end |
| <fieldset> | |
| <%= f.text_field :university, placeholder: "#{t(:university, scope: 'activerecord.attributes.educational_experiences')}" %> | |
| <%= f.text_field :major, placeholder: "#{t(:major, scope: 'activerecord.attributes.educational_experiences')}" %> | |
| <%= f.text_field :minor, placeholder: "#{t(:minor, scope: 'activerecord.attributes.educational_experiences')}" %> | |
| <%= f.hidden_field :_destroy %> | |
| <%= link_to "[remove]", "#", class: "remove_fields" %> | |
| </fieldset> |
| <fieldset> | |
| <%= f.text_field :university, placeholder: "#{t(:university, scope: 'activerecord.attributes.educational_experiences')}" %> | |
| <%= f.text_field :major, value: f.object.major placeholder: "#{t(:major, scope: 'activerecord.attributes.educational_experiences')}" %> | |
| <%= f.text_field :minor, value: f.object.minor placeholder: "#{t(:minor, scope: 'activerecord.attributes.educational_experiences')}" %> | |
| <% unless f.object.new_record? %> | |
| <%= f.hidden_field :_destroy %> | |
| <%= link_to "[remove]", "#", class: "remove_fields" %> | |
| <% end %> | |
| </fieldset> |
| NoMethodError in ItemsController#import | |
| undefined method `each' for nil:NilClass | |
| Extracted source (around line #27): | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 |
| #the user model contains this association: | |
| has_one :employee, autosave: true | |
| # The auth hash contains all necessary data | |
| def self.from_omniauth(auth) | |
| where(auth.slice(:provider, :uid)).first_or_initialize.tap do |user| | |
| user = User.create \ | |
| provider: auth.provider | |
| uid: auth.uid | |
| name: auth.info.name |
| # WAT |
| var Script = require('deployd/lib/script'); | |
| var _run = Script.prototype.run; | |
| Script.prototype.run = function(ctx, domain, fn) { | |
| if (typeof domain === 'object') { | |
| domain.require = function(module) { | |
| return require(module); | |
| }; | |
| domain.context = function() { // access Context via context() | |
| return ctx; |
| def self.total_volume(transactions) | |
| return transactions.amount unless transactions.is_a? Array | |
| transactions.reduce(0) do |total, transaction| | |
| total += transaction.amount | |
| end | |
| end |