Matt Plaidcorp
2007-Aug-09 17:53 UTC
how do i list strings vertically down a website from a datab
hi, I need to set up a page that lists words vertically, these words will be read from a database. I would also like a text box at the bottom of the list ready to add new words to the database, then have the newly added word appear at the end of the list. I own the agile web dev with rails book, but I cant get a pure answer to my question from it. If you could just give me some lines of code you think would work that would be great. this is an example: hello whats up hi>>text box<< "how are you" (''how are you'' is entered into the text box)(the site will then reload and come back with this) hello whats up hi how are you>>text box<<-- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
nigel.bris
2007-Aug-09 23:56 UTC
Re: how do i list strings vertically down a website from a datab
This would probably do what you want.... It would be more fun done ajax calls (no page refresh) but this gives you the starting idea ---Controller class SimpleListController < ApplicationController def index @items = SimpleList.find(:all, :order=>"id") end def create_item unless params[:display_text].empty? @items = SimpleList.create(:display_text=>params[:display_text]) end redirect_to :action=>:index end end ---- View <% for item in @items -%> <%=item.display_text %><br> <% end -%> <% form_tag :action=>:create_item do -%> <%=text_field_tag :display_text %> <%=submit_tag "Add" %> <% end %> On Aug 10, 3:53 am, Matt Plaidcorp <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> hi, > > I need to set up a page that lists words vertically, these words will be > read from a database. I would also like a text box at the bottom of the > list ready to add new words to the database, then have the newly added > word appear at the end of the list. > > I own the agile web dev with rails book, but I cant get a pure answer to > my question from it. If you could just give me some lines of code you > think would work that would be great. > > this is an example: > > hello > whats up > hi > > >>text box<< "how are you" (''how are you'' is entered into the text box) > > (the site will then reload and come back with this) > > hello > whats up > hi > how are you>>text box<< > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Plaidcorp
2007-Aug-10 15:13 UTC
Re: how do i list strings vertically down a website from a d
Mr. Bris, Thank you for this code, this is definitely what I needed. There are a couple problems that I still need your help on; when I ran the code on localhost it came back with an error: Showing app/views/sample_list/add.rhtml where line #5 raised: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Extracted source (around line #5): 2: <head> 3: <title>please enter a word...</title> 4: </head> 5: <% for item in @items -%> 6: <%=item.display_text %><br> 7: <% end -%> 8: <% form_tag :action=>:create_item do -%> It talks about an unexpected nil character, so I''m thinking that I should load the database with the first entry. If you think that is the case, should I do some type of migration to make a new table in the DB? In any event I would like to get your feed back. Thanks again, Matt -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
nigel.bris
2007-Aug-10 21:47 UTC
Re: how do i list strings vertically down a website from a d
This should be the code in your migration file after you generated a model... class CreateSimpleLists < ActiveRecord::Migration def self.up create_table :simple_lists do |t| t.column :display_text, :string end end def self.down drop_table :simple_lists end end then "rake db:migrate" On Aug 11, 1:13 am, Matt Plaidcorp <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Mr. Bris, > > Thank you for this code, this is definitely what I needed. There are a > couple problems that I still need your help on; when I ran the code on > localhost it came back with an error: > > Showing app/views/sample_list/add.rhtml where line #5 raised: > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.each > > Extracted source (around line #5): > > 2: <head> > 3: <title>please enter a word...</title> > 4: </head> > 5: <% for item in @items -%> > 6: <%=item.display_text %><br> > 7: <% end -%> > 8: <% form_tag :action=>:create_item do -%> > > It talks about an unexpected nil character, so I''m thinking that I > should load the database with the first entry. If you think that is the > case, should I do some type of migration to make a new table in the DB? > In any event I would like to get your feed back. > > Thanks again, > > Matt > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Plaidcorp
2007-Aug-13 14:26 UTC
Re: how do i list strings vertically down a website from a d
Mr. Bris I did the migration, it showed up in the database but I still get the same error. I tried putting something manually into the database, to have a string in there for the code to grab, but it would not let me. Is there anything else I''m not doing or seeing? Thanks Matt -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Matt Plaidcorp
2007-Aug-13 15:04 UTC
Re: how do i list strings vertically down a website from a d
to load the db, I made an admin controller and put scaffold :sample in it, but the same error keeps coming up. -- 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 post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---