[Rails] Create and join two models in one form (HABTM)

2010-11-09 Thread David Raffauf
What is the best approach for using one form to create two different models and join them? I'm working with a HABTM relationship. For example a project HABTM services and vice versa. I've tried using accepts_nested_attributes_for which seems to work when I'm creating a project and using a servic

[Rails] Nested Forms and HABTM fails for existing model, no join record

2010-11-07 Thread David Raffauf
I am trying to created a nested form with a HABTM association and I am unable to find an approach that works for all cases. What I am trying to achieve is a Project form that can: 1. Create a new project and create new company to associate with it - This works perfectly 2. Create a new project

[Rails] Re: Modelling parent/child accounts with other models

2010-10-12 Thread David Raffauf
Playing around with my new model I feel like I've made a good decision with the modeling. If I were to make an ER diagram, I've effectively made a sandwich with Projects on the top, all my supporting models and relationships in the middle, and People and Accounts on the bottom. I've linked Acc

[Rails] Re: Modelling parent/child accounts with other models

2010-10-12 Thread David Raffauf
Thanks for the responses. I think my application probably matches the Basecamp style of account handling. I think for simplicity I can keep everything project-centric and use the accounts to show who owns which projects @account.projects @account.projects.companies @account.projects.people @a

[Rails] Modelling parent/child accounts with other models

2010-10-11 Thread David Raffauf
I am creating an application that involves: Accounts People (Many people belong to one account) ..and various other models... Companies Projects Services ... I'm trying to find what the best way is to denote that any of the non-account related model records belong to an account. So using the

[Rails] Re: Migration update with multiple joined tables

2010-04-10 Thread David Raffauf
def self.up execute "UPDATE posts SET state_id = (SELECT states.id FROM states, zips WHERE posts.zip_id = zips.id AND states.abbreviation = zips.state)" end def self.down Post.find(:all).each { |post| post.update_attribute :state_id, nil } end -- Posted via http://www.ruby-forum

[Rails] Re: Migration update with multiple joined tables

2010-04-10 Thread David Raffauf
I found out about execute statements, but then I also learned that sqlite3 doesn't support this syntax. I'm not sure what to do. This seems like a common need. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rai

[Rails] Migration update with multiple joined tables

2010-04-10 Thread David Raffauf
I'm trying to do an update that requires table joins but I can't find any examples of updates beyond simple attribute value assignments. I have a select statement like this: SELECT title, state, name FROM posts, zips, states WHERE posts.zip_id = zips.id AND states.abbreviation = zips.state; The

[Rails] Re: Add a method for approving/disapproving content

2010-03-16 Thread David Raffauf
> > Dave, can you post your model file? > Thanks Conrad. I found a workaround and got some pointers on how to build the links. I'll report back on the link approach tomorrow. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Gr

[Rails] Add a method for approving/disapproving content

2010-03-16 Thread David Raffauf
Hey everyone, This is my first post to the forums. I'm trying to add an 'approve' and 'disapprove' link for new content to my website. I thought I should just add two links to the "show" view to trigger the "approve" and "disapprove" method. Clicking these links doesn't have any effect in the D