Questions tagged [virtual-attribute]

113 questions
0
votes
1 answer

@model.map(&:attributes) and virtual attributes

How can i use @model.map(&:attributes) to make it so that virtual attributes show up in when I render @model as json
p01nd3xt3r
  • 821
  • 1
  • 9
  • 19
0
votes
1 answer

Timezone-affected rails 3 app

UPDATE: Copied from comment made below: I thought about using a web service against IP address for each visitor to the site but then I wondered about users looking at meetings in locations that span timezones so the timezone has to be associated…
user1116573
  • 2,817
  • 4
  • 17
  • 27
0
votes
1 answer

Rails 3 validates_uniquess_of virtual field with scope

I am working on a Rails 3 app that is needing to run a validation on a virtual field to see if the record already exists... here is my model code: #mass-assignment attr_accessible :first_name, :last_name, :dob, :gender …
dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
0
votes
2 answers

ActiveRecord association getting saved before the record in an update

I have an Entry model which has many Tags. Tags are added to an entry by typing them into a textbox on my form, via a tag_names virtual attribute. Before validation on the Entry model, the tag_names string is converted into actual Tag objects using…
Daniel Vandersluis
  • 91,582
  • 23
  • 169
  • 153
0
votes
1 answer

How can i override an attribute from another virtual attribute in a model?

I have a virtual attribute start_date and a database column start (datetime). How can i override the date (but not the time) of start with the date from start_date? I tried this in the setter method and the logger says that self.start/start is set,…
tonymarschall
  • 3,862
  • 3
  • 29
  • 52
0
votes
1 answer

Setting a virtual attribute in a scope

I am trying to find a way of setting a virtual attribute in a scope. The background is I have customers who belong to accounts. Customers can purchase salesitems. I have a table customers_salesitem that shows which customers have bought what…
cpt_peter
  • 399
  • 2
  • 11
-1
votes
1 answer

Virtual attributes and inheritance super with Ruby

I'm taking a ruby fundamentals counse in pluralsight but some of the code from the instructor isn't working. Could someone please explain what's missing & why whatever is missing is needed? Thank you so much class Probe def deploy(deploy_time,…
cloud712
  • 25
  • 1
  • 3
-1
votes
1 answer

Rails nested models and virtual attribute initialization

I have a problem understanding how are attributes "sent" to nested model(s), and if is possible to do this for model with virtual attrubute too. I have three models: class User < ActiveRecord::Base ... has_and_belongs_to_many :clearancegoods …
1 2 3 4 5 6 7
8