similar to: Bad idea to add/remove associations in after_find

Displaying 20 results from an estimated 7000 matches similar to: "Bad idea to add/remove associations in after_find"

2006 Dec 14
12
Saving dates
Hi having trouble saving dates in my form i have the following in the view <%= date_select("details", "open_date") %> and i have @exhibition.open_date = params[:details][:open_date] and then @exhibition.save All the other values form (not seen here) get saved but not the dates. What am i doing wrong ? -- Posted via http://www.ruby-forum.com/.
2009 Oct 08
6
Eager Loading a Relationship That Has No PK/FK
I''m attempting to wrestle an old DB into Rails. This relationship is giving me trouble: class Show < AR::Base has_many :segments end class Segment < AR::Base belongs_to :show has_one :media #this has no PK/FK relation end A Segment is "linked" to Media by Media.name, which is the result of concatenating Segment.name and Segment.part. As I said there are is no
2006 Mar 31
1
many to one :through another
Since has_one :colour :through => :species isn''t supported (for some reason unknown to me), can anyone forsee any problems that the following workaround might cause (in the Photo class). has_many :artists, :through => :artist_photos has_one :artist_photo So effectively, the has_many statement gives me the through functionality I need, but the has_one restricts the program to only
2006 Apr 16
5
Granular model validation based around controller actions?
How can I achieve granular control over the validation for different controllers? I create users from an administration controller, but I don''t want to fill in all their information fields, just have their name and email address. When they accept the invitation, I want to implement validation on the other fields. I have looked at using :on => :update, but I would have to make the
2006 May 17
2
ActiveRecord::Associations ER diagram/macros
Hello, I found an interesting ER diagram on the "Module: ActiveRecord::Associations::ClassMethods" page of the Rails Framework Documentation : http://ar.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html At the beginning we can read ? Associations are a set of macro-like class methods for tying objects together through foreign keys. They express relationships like
2013 Mar 05
4
searching model and has_one association
Howdy. I have these models: User, field "mundane_name" user has_one :instructor_profile (may or may not exist) instructor_profile, field "sca_name" belongs_to :user I would like to craft a search on these fields, which is effectively this, but in one go: matching_users = User.where("mundane_name ILIKE ?", "%#{target}%") matching_profiles =
2006 May 18
9
Possible solutions to txtdrive process killing for cpu usage
Hi, I''ve just deployed a basic ecommerce site on textdrive.com. The application has been stress tested on our local development machines and appears to be running fine (no memory leaks). However, on textdrive the fcgi processes are being killed after just a few requests apparently because of cpu usage (The log says the processes exceeds 17% average cpu usage in the last few minutes)
2005 Apr 18
11
Create a pseudo-model from SQL query?
I''m having a hard time figuring out how to build my application using Rails. As i go along, simple questions occur to me like: are you supposed to have a separate model class (each in its own file, in the app/models directory) for each table in your database? You''d think that something as basic as this would be laid out in the introductory documentation but, alas, the
2007 Jul 25
5
set_default_values rocket science - continuing after_initialize/after_find misfeature
Just starting a new thread so that it''s easy to follow. I just submitted a patch at trac to add a new class method called "set_default_values" ( not a great name I think ), which lets you do all kinds of crazy stuff with setting default values. This ticket is at http://dev.rubyonrails.org/ticket/9093 and example pastie is at http://pastie.caboo.se/81925 It also lets you make
2005 Nov 04
0
after_find callback in an acts_as plugin
Hi, I am thinking about writing an acts_as_fox plugin that defines an after_find callback method. If I do this what will happen if a user creates a model that acts_as_fox but this model has it''s own after_find callback method? I imagine that the model''s after_find method shadows the plugin''s after_find. Presumably both after_find callbacks would need to be performed but
2006 Jan 22
11
ActiveRecord find
Suppose I have three tables - authors, posts and topics. Every post have a topic and every topic has an author, so I have posts.topic_id and topic.author_id. When the author is guest (not registered), author_id is nil. I need to find all the posts (in one query) where every post have all the information of the topic and the auther, so if p is one of those posts I could get the name of the
2013 Jul 05
7
how to use single login page for users in four models
how to use single login page for users in four models -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group,
2005 May 13
17
modeling...
I''ve tried tackling this many ways on my own and can''t find a good solution: Breaking it down to something simplier... Venue has one address Person has one address Address belongs to state Assuming I don''t want to do tables for venue_addresses and person_addresses. What is the best way to model this using rails... big thing here is i want to be able to reuse a
2006 Aug 09
7
function before_save
Hi everybody I would like a function as the "before_save" method in the model. But it must be the opposite. When I take out data from the database through the model, I want to call a function before the data are available in the controller. Can anyone help me? ---- >>>> thx <<<< ---- -- Posted via http://www.ruby-forum.com/.
2010 Oct 15
1
Help with nested form: User and Artist
Artist is 1:1 with User. User has_one :artist In my artist model, I have: belongs_to :user accepts_nested_attributes_for :user However, in my artist _form, the name column from the user model does not display. I am doing: <% f.fields_for :user do |builder| %> <p class="fields"> <%= builder.label :name %> <%= builder.text_field :name %>
2012 Jan 27
3
How to test the model dependence ?
Good morning, I''m new to rails and am having some basic questions in development. See if anyone can help me with a test problem. I need to test if my model "Procedure" is linked to the workflow. If not, the system must acknowledge an error. Below is the code that is in the file test \ unit \ procedure_test.rb. require ''test_helper'' class ProcedureTest <
2013 Aug 29
10
Concatenate two arrays
Hello again ruby community! I just learned how to add two arrays(I know, i know). My program looked like this array1=[1,2,3] array2=[4,5,6] array_sum=array1+array2 I thought pretty simple stuff, they are combined. However, now i am looking to define that code as a method and I do not understand how to create the correct number of arguments, so when the method is called back it gives me my
2006 Jul 05
2
Serialized object behaves weird
Hi! I got a class named EinsatzFilter which I serialized to session. Before saving to session it works afterwards I keep getting the message: "undefined method `to_s'' for #<Person:0x38c6ab8>". "Person" is a from ActiveRecord::Base inherited class. Code: class EinsatzFilter include ApplicationHelper attr_reader :personen, :monat, :projekte, :kunde
2013 Jul 24
12
Want to send password via SMS
Hi I am saving password with hashed_password and salt in table. Now I need to send those passwords via SMS can it be possible.Kindly give me some suggestion plz . Thanks in advance Cheers -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to
2006 Jan 29
8
Determining width and height of image files
I''m trying to figure out how to determine the width and height of images that are uploaded through my app. Either from the posted data or the file I save to disk. I''ve been searching around for info but no luck; I''m completely at a loss. Any suggestions or pointers would be great. Project background: The site is an artists portfolio site. The images are thumbnails