similar to: combining two models in one controller/view "set"

Displaying 20 results from an estimated 6000 matches similar to: "combining two models in one controller/view "set""

2006 Mar 31
4
How to have a form within a form?
Say I am building a blogging platform, and I want to allow users to be able to add an avatar without leaving the page, when they''re writing a post. I need the avatar information to be included in the form for the post. So for example, after a user adds a new avatar while writing a new blog post, it would be available to be selected as the avatar to be used for that post. What is
2006 Mar 24
3
Pilot to Bombardier
do you read me? Testing, one, two, three... not seeing my post -- just want to make sure its working.
2006 Mar 15
10
Scaffold with Foreign Key
I have two tables: ------------------------------ drop table if exists users; create table users ( id int not null auto_increment, username varchar(100) not null, password varchar(20) not null, firstname varchar(20) not null, lastname varchar(20) not null, primary key (id) ) TYPE = InnoDB; ------------------------------ drop table
2006 Jan 27
6
Scaffolding to use has_many and belongs_to ?
What does everyone on this list think about enhancing scaffolding somehow so that a "has_many" relationship will automatically drop the <select> box into the view to reference the "belongs_to" part of the view? I think scaffolding is great but I am always adding the <select> boxes to reference the parent association. Do you think this would be useful? just a
2006 Apr 05
13
scaffold misuse?
Running ruby script/generate scaffold Product Admin is a wonderful way to set up well, exactly what it says, a scaffold. My problem is that I have several other tables that are linked, through foreign keys, to the Product table. Say an "authors" table. Now when I go enter a new product, a book, I want the application to provide a drop down list of authors generated from the records in
2006 May 19
4
Lookup tables and scaffolding
It occurs to me as a missing feature that there''s no way to indicate a lookup table relationship (as opposed to other sorts of foreign key relationships) in Rails and that the scaffolding generator could recognise this lookup and render a drop-down list automagically for the lookup table. Say you have an Address and a State, and the State is a lookup table. In addresses you have
2006 Jan 09
6
Nil column results, possible to ignore?
For a table "clients" there are city, state, and zip fields. However, for some clients we only have a state with no actual address. The following code throws a "You have a nil object" error when outputting my client list. Is there a way around this, short of writing a specific case for each possibility? &lt;%= client.city + '', '' + client.state +
2006 Jun 08
3
MVC and Pagination
Just wondering how to best integrate with pagination and still stick to MVC... Say I have a Post model that has a published attribute. I want to show all the recent published posts on a page. My first instinct is to create a method in the Post model called recent that does the find with proper conditions and order, but the problem I have is how do I use that with pagination (which definitely
2006 Aug 01
5
MVC question
Should I create a separate controller for each model or should I use 1 controller for all models? Having 1 "admin" controller for all backend stuff seems logic to me, but when I scaffold it rather makes 1 controller per model. I''m fairly new to the MVC pattern, so what''s the prefered way of doing it? I''m also wondering if the API is up to date? When
2006 Jan 12
3
Introspecting Active Record Associations
Hi, I''m looking into write scaffold generators that will, amoung other things, scaffold active record associations (eg. generate select boxes for belongs_to where you can choose a parent object) for quicker prototyping. But... My question is: Is there anyway of finding out what associations exist from examining the lodel classes themselves or indeed any other way of finding out this
2006 Mar 23
2
Question About Scaffolding for My First Rails App
When using ruby to generate scaffolding, is there an easy way to add features that would be useful for keeping track of has_many and belongs_to relations? For example, suppose I have the following: Users Sites Pages Modules Each user has many pages, each site has many pages, each page has many modules, and also the belongs_to relation holds in the opposite order. I''m using the
2006 Jan 12
9
Scaffold shows all attributes altough I use attr_accessible!
Hi all I have a Model like this: class Member < ActiveRecord::Base attr_accessible :username, :email, :first_name, :last_name end I have created a scaffold using script/generate scaffold member members Using the URL localhost:3000/members/edit/1 I can edit all attributes, including created_at, lock_version etc.! But it should only show the attributes I listed in attr_accessible! What
2006 Jan 13
4
missing foreign key fields in scaffold views
Is there any reason that foreign key fields do not show in any of the scaffold views ? project table: id serial primary key, category_id integer, user_id integer, name varchar, morestuff varchar foreign key (category_id) references categories(id), foreign key (user_id) references users(id) scaffold generated views only show name, morestuff fields
2006 Aug 14
5
UML
In Rolling with Ruby on Rails tutorial - http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html - I saw that to introduce a new element to my domain, I needed to define it in a table, generate a model element with a similar name and the class would autoamtically take the attributes from the table definition. Is it possible to do this in the other direction... i.e to take the class diagram
2007 Jun 02
7
I''m really bad at controllers, help please.
Hey, Sorry for so many questions - I''m really bad at this right now. I''m trying to cover the following code w/ rspec def index if params[:user_id] @user = User.find(params[:user_id]) @messages = @user.messages end end So basically what I''m doing is listing all the messages for a user, provided there is an id parameter. describe
2006 May 01
4
When to make a new controller
Hey all, Ok this is probably a newb question, but I haven''t been programming with MVC for very long, and I''ve been wondering what the general opinion is, or best practices, for making a new controller. Like what cases would you need a new controller for and what cases can you just put everything into one controller? Thanks in advance, Randal -- Posted via
2009 Jun 29
2
include-from with different source points
Trying to automate backup of the following local mounts/directories to a usb drive (/mnt/usbbackup); here's what's in my include file: + /home/gravyface/www/* + /mnt/datadisk1/music/* + /mnt/datadisk2/projects/* If I run the following, nothing happens, so I checked the man and I'm not specifying a source (I thought the include-from was the source): sudo rsync --progress -avz
2006 Mar 29
4
Scaffold generator: create vs. new
Can anyone supply me with a simple, succinct explanation of what the difference is between the "new" controller and the "create" controller that the scaffold generator produces? I run: > script/generate scaffold modelname controllername And now I need to do some work inside the controllername.rb file. For example, pulling a list from another database table to supply
2009 May 24
6
belongs_to not saving foreign key
Under Rails 2.3.2 using a completely brand new project, I have 2 models: class Author < ActiveRecord::Base # name:string end class Book < ActiveRecord::Base # title:string belongs_to :author # author_id end And a simple test where i create a Book with an Author using the belongs_to and then update the foreign key directly: require ''test_helper'' class BookTest
2005 Dec 17
3
Can scaffold generate listboxes in views? I''ve been unsuccessful.
I''ve created several different Rails applications but I''m running into the same trouble with each one. Lets say I create an app called Test. I type ''rails test'' and it generates the directory for me. Now I edit my database.yml file. Then I create a database with Postgresql by typing createdb test. Now I go into Postgresql by typing ''psql