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 if exists listings; create table listings ( id int not null auto_increment, user_id int not null, description text not null, constraint fk_listings_user foreign key (user_id) references users(id), primary key (id) ) TYPE = InnoDB; ------------------------------ and in my User model i have the line: has_many :listing and in my Listing model i have the line: belongs_to :user I generate my scaffold: ruby script\generate Scaffold User Useradmin ruby script\generate Scaffod Listing Listingadmin the problem I''m having is that the scaffold view that is generated for Listing does not have an entry for selecting a User. In fact, the scaffold skips the user_id column completely. -- Vince -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060315/18b635ea/attachment.html
On Tue, 2006-03-14 at 22:54 -0800, Vincent Gov wrote:> 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 if exists listings; > create table listings ( > id int not null auto_increment, > user_id int not null, > description text not null, > constraint fk_listings_user foreign key (user_id) references > users(id), > primary key (id) > ) TYPE = InnoDB; > ------------------------------ > and in my User model i have the line: > has_many :listing > > and in my Listing model i have the line: > belongs_to :user > > I generate my scaffold: > ruby script\generate Scaffold User Useradmin > ruby script\generate Scaffod Listing Listingadmin > > the problem I''m having is that the scaffold view that is generated for > Listing does not have an entry for selecting a User. In fact, the > scaffold skips the user_id column completely. >---- shouldn''t user model be... has_many :listings Craig
Thanks. Just tried that.. It didn''t work though. On 3/14/06, Craig White <craigwhite@azapple.com> wrote:> > On Tue, 2006-03-14 at 22:54 -0800, Vincent Gov wrote: > > 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 if exists listings; > > create table listings ( > > id int not null auto_increment, > > user_id int not null, > > description text not null, > > constraint fk_listings_user foreign key (user_id) references > > users(id), > > primary key (id) > > ) TYPE = InnoDB; > > ------------------------------ > > and in my User model i have the line: > > has_many :listing > > > > and in my Listing model i have the line: > > belongs_to :user > > > > I generate my scaffold: > > ruby script\generate Scaffold User Useradmin > > ruby script\generate Scaffod Listing Listingadmin > > > > the problem I''m having is that the scaffold view that is generated for > > Listing does not have an entry for selecting a User. In fact, the > > scaffold skips the user_id column completely. > > > ---- > shouldn''t user model be... > > has_many :listings > > Craig > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Vincent H Gov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060315/e46e9719/attachment.html
On Tue, 2006-03-14 at 23:10 -0800, Vincent Gov wrote:> Thanks. Just tried that.. It didn''t work though. > > On 3/14/06, Craig White <craigwhite@azapple.com> wrote: > On Tue, 2006-03-14 at 22:54 -0800, Vincent Gov wrote: > > 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 if exists listings; > > create table listings ( > > id int not null auto_increment, > > user_id int not null, > > description text not null, > > constraint fk_listings_user foreign key (user_id) > references > > users(id), > > primary key (id) > > ) TYPE = InnoDB; > > ------------------------------ > > and in my User model i have the line: > > has_many :listing > > > > and in my Listing model i have the line: > > belongs_to :user > > > > I generate my scaffold: > > ruby script\generate Scaffold User Useradmin > > ruby script\generate Scaffod Listing Listingadmin > > > > the problem I''m having is that the scaffold view that is > generated for > > Listing does not have an entry for selecting a User. In > fact, the > > scaffold skips the user_id column completely. > > > ---- > shouldn''t user model be... > > has_many :listings > > Craig---- to be honest...I''ve always used pop-up selectors or auto_complete selectors for this phase because the id is just some sequential number that is not meaningful at all anyway. I''m not sure about the scaffold methodology and don''t rely upon it getting everything done for me beyond the specific table I am scaffolding. Thus, in app/views/listings # and I''m too used to Linux to turn my / into \ I would have a selector like... (watch email line wraps) <p><label for="listing_user_name">User</label><br/> <%= options = [[''Select a User'', '''']] + @user.sort{|a,b| a.name <=> b.name }.collect { |u| [u.name, u.id] } select ''listing'', ''user_id'', options %></p> Craig
Vincent Gov wrote:> 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 if exists listings; > create table listings ( > id int not null auto_increment, > user_id int not null, > description text not null, > constraint fk_listings_user foreign key (user_id) references users(id), > primary key (id) > ) TYPE = InnoDB; > ------------------------------ > and in my User model i have the line: > has_many :listing > > and in my Listing model i have the line: > belongs_to :user > > I generate my scaffold: > ruby script\generate Scaffold User Useradmin > ruby script\generate Scaffod Listing Listingadmin > > the problem I''m having is that the scaffold view that is generated for > Listing does not have an entry for selecting a User. In fact, the > scaffold > skips the user_id column completely.Scaffolding is a temporary framework used to support people and material in the construction or repair of buildings and other large structures.[1] As you can from the aboce citation, scaffolding is a temporary structure as you build out the rest of your application. It does not support any typ of association. Joey http://www.feedreed.com [1] http://en.wikipedia.org/wiki/Scaffolding -- Posted via http://www.ruby-forum.com/.
I understand the concept. I just thought that Rails scaffolding would recognize the column and create a pull down menu for me. The work isnt really hard to do, but since this column is a constraint in my table, it would be a lot more efficient if rails had made a generic form object for it. If Rails is incapable of that and the problem with foreign keys is a general case for Rails scaffolding, then I will proceed to add my own form objects. On 3/14/06, joey__ <cardologist@gmail.com> wrote:> > Vincent Gov wrote: > > 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 if exists listings; > > create table listings ( > > id int not null auto_increment, > > user_id int not null, > > description text not null, > > constraint fk_listings_user foreign key (user_id) references users(id), > > primary key (id) > > ) TYPE = InnoDB; > > ------------------------------ > > and in my User model i have the line: > > has_many :listing > > > > and in my Listing model i have the line: > > belongs_to :user > > > > I generate my scaffold: > > ruby script\generate Scaffold User Useradmin > > ruby script\generate Scaffod Listing Listingadmin > > > > the problem I''m having is that the scaffold view that is generated for > > Listing does not have an entry for selecting a User. In fact, the > > scaffold > > skips the user_id column completely. > Scaffolding is a temporary framework used to support people and material > in the construction or repair of buildings and other large > structures.[1] > > As you can from the aboce citation, scaffolding is a temporary structure > as you build out the rest of your application. It does not support any > typ of association. > > Joey > http://www.feedreed.com > > [1] http://en.wikipedia.org/wiki/Scaffolding > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Vincent H Gov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060315/11670612/attachment-0001.html
I think I provided the code to do that last night before I went to bed but as ''joey'' says...I haven''t seen scaffold do that sort of thing...perhaps in the future... Craig On Wed, 2006-03-15 at 10:04 -0800, Vincent Gov wrote:> I understand the concept. I just thought that Rails scaffolding would > recognize the column and create a pull down menu for me. The work > isnt really hard to do, but since this column is a constraint in my > table, it would be a lot more efficient if rails had made a generic > form object for it. If Rails is incapable of that and the problem > with foreign keys is a general case for Rails scaffolding, then I will > proceed to add my own form objects. > > On 3/14/06, joey__ <cardologist@gmail.com> wrote: > Vincent Gov wrote: > > 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 if exists listings; > > create table listings ( > > id int not null auto_increment, > > user_id int not null, > > description text not null, > > constraint fk_listings_user foreign key (user_id) references > users(id), > > primary key (id) > > ) TYPE = InnoDB; > > ------------------------------ > > and in my User model i have the line: > > has_many :listing > > > > and in my Listing model i have the line: > > belongs_to :user > > > > I generate my scaffold: > > ruby script\generate Scaffold User Useradmin > > ruby script\generate Scaffod Listing Listingadmin > > > > the problem I''m having is that the scaffold view that is > generated for > > Listing does not have an entry for selecting a User. In > fact, the > > scaffold > > skips the user_id column completely. > Scaffolding is a temporary framework used to support people > and material > in the construction or repair of buildings and other large > structures.[1] > > As you can from the aboce citation, scaffolding is a temporary > structure > as you build out the rest of your application. It does not > support any > typ of association. > > Joey > http://www.feedreed.com > > [1] http://en.wikipedia.org/wiki/Scaffolding > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > -- > Vincent H Gov > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Thanks Craig, I''ll try it. I guess I was just surprised to run into this issue. Rails seemed to take care of every administrative task up until this one. On 3/15/06, Craig White <craigwhite@azapple.com> wrote:> > I think I provided the code to do that last night before I went to bed > but as ''joey'' says...I haven''t seen scaffold do that sort of > thing...perhaps in the future... > > Craig > > On Wed, 2006-03-15 at 10:04 -0800, Vincent Gov wrote: > > I understand the concept. I just thought that Rails scaffolding would > > recognize the column and create a pull down menu for me. The work > > isnt really hard to do, but since this column is a constraint in my > > table, it would be a lot more efficient if rails had made a generic > > form object for it. If Rails is incapable of that and the problem > > with foreign keys is a general case for Rails scaffolding, then I will > > proceed to add my own form objects. > > > > On 3/14/06, joey__ <cardologist@gmail.com> wrote: > > Vincent Gov wrote: > > > 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 if exists listings; > > > create table listings ( > > > id int not null auto_increment, > > > user_id int not null, > > > description text not null, > > > constraint fk_listings_user foreign key (user_id) references > > users(id), > > > primary key (id) > > > ) TYPE = InnoDB; > > > ------------------------------ > > > and in my User model i have the line: > > > has_many :listing > > > > > > and in my Listing model i have the line: > > > belongs_to :user > > > > > > I generate my scaffold: > > > ruby script\generate Scaffold User Useradmin > > > ruby script\generate Scaffod Listing Listingadmin > > > > > > the problem I''m having is that the scaffold view that is > > generated for > > > Listing does not have an entry for selecting a User. In > > fact, the > > > scaffold > > > skips the user_id column completely. > > Scaffolding is a temporary framework used to support people > > and material > > in the construction or repair of buildings and other large > > structures.[1] > > > > As you can from the aboce citation, scaffolding is a temporary > > structure > > as you build out the rest of your application. It does not > > support any > > typ of association. > > > > Joey > > http://www.feedreed.com > > > > [1] http://en.wikipedia.org/wiki/Scaffolding > > > > > > -- > > Posted via http://www.ruby-forum.com/. > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > > -- > > Vincent H Gov > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Vincent H Gov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060315/7180f178/attachment.html
On 3/15/06, Vincent Gov <vincehgov@gmail.com> wrote:> I understand the concept. I just thought that Rails scaffolding would > recognize the column and create a pull down menu for me. The work isnt > really hard to do, but since this column is a constraint in my table, it > would be a lot more efficient if rails had made a generic form object for > it. If Rails is incapable of that and the problem with foreign keys is a > general case for Rails scaffolding, then I will proceed to add my own form > objects.Take a look at the Scaffolding Extensions plugin: http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin.
looks like what i need. Whats the difference between edge rails and regular rails? On 3/15/06, Jeremy Evans <jeremyevans0@gmail.com> wrote:> > On 3/15/06, Vincent Gov <vincehgov@gmail.com> wrote: > > I understand the concept. I just thought that Rails scaffolding would > > recognize the column and create a pull down menu for me. The work isnt > > really hard to do, but since this column is a constraint in my table, it > > would be a lot more efficient if rails had made a generic form object > for > > it. If Rails is incapable of that and the problem with foreign keys is > a > > general case for Rails scaffolding, then I will proceed to add my own > form > > objects. > > Take a look at the Scaffolding Extensions plugin: > http://wiki.rubyonrails.com/rails/pages/Scaffolding+Extensions+Plugin. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Vincent H Gov -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060316/9acc4458/attachment.html