I am having a problem where I am getting data from a form and when it get puts into the database there is extra unwanted junk there, and I don''t know why it is doing it. Has anyone had any problems like this? -- 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 -~----------~----~----~----~------~----~------~--~---
Scott Pn wrote:> I am having a problem where I am getting data from a form and when it > get puts into the database there is extra unwanted junk there, and I > don''t know why it is doing it. Has anyone had any problems like this?Anything that is saved in the database would be going through any validations and filters that you put in place. Perhaps you could elaborate on what "junk" is. Robby -- Robby Russell http://www.robbyonrails.com/ http://www.planetargon.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 -~----------~----~----~----~------~----~------~--~---
Robby Russell wrote:> Anything that is saved in the database would be going through any > validations and filters that you put in place. > > Perhaps you could elaborate on what "junk" is. > > Robby > > -- > Robby Russell > http://www.robbyonrails.com/ > http://www.planetargon.com/well it puts in --- - when I do a submit to the db. -- 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 -~----------~----~----~----~------~----~------~--~---
it puts in --- - ? you mean dashes? and where does it put that in? what column? what column type? what does your model and controller code look like? We''re no mindreaders mister ;) On 27 Jul., 13:36, Scott Pn <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Robby Russell wrote: > > Anything that is saved in the database would be going through any > > validations and filters that you put in place. > > > Perhaps you could elaborate on what "junk" is. > > > Robby > > > -- > > Robby Russell > >http://www.robbyonrails.com/ > >http://www.planetargon.com/ > > well it puts in --- - when I do a submit to the db. > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thorsten wrote:> it puts in --- - ? > you mean dashes? and where does it put that in? what column? what > column type? what does your model and controller code look like? > > We''re no mindreaders mister ;)Sorry, should have just posted some code in the first place. Here is the partial I am using to submit the comment. (/partial/_add_comment.rhtml): <div class="comment"> <% form_tag :controller => ''comment'', :action => ''add_comment'' do %> <label>Add a Comment:</comment><br /> <%= text_area :comment, params[:comment], :value => '''', :cols => "55", :rows => "6" %><br /> <%= hidden_field :id, params[:id], :value => params[:id] %> <%= hidden_field :user_id, params[:user_id], :value => session[:user_id] %> <%= submit_tag "Add Comment" %> <% end %> </div> Here is the controller code that creates the comment object and puts it into the DB: def add_comment @comment = Comment.new @comment.comment = params[:comment] @comment.user_id = params[:user_id] @comment.date = Time.now if @comment.save flash[:notice] = "Comment added successfully" redirect_to(:controller => :profile, :action => :show, :id => params[:id]) else flash[:notice] = "Comment didn''t submit properly, please try again later" end end And the model looks like this: class Comment < ActiveRecord::Base belongs_to :users validates_presence_of :comment end -- 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 -~----------~----~----~----~------~----~------~--~---
Oh yeah I should mention it puts "|---- - comment here" into the db table (to be a little more precise on what I meant by junk). -- 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 -~----------~----~----~----~------~----~------~--~---
Scott Pn wrote:> Oh yeah I should mention it puts "|---- - comment here" into the db > table (to be a little more precise on what I meant by junk).That string is coming from somewhere. I''m guessing it''s a mistyped HTML comment in one of your view files. Look at the HTML source of the page after its been rendered by Rails to see where that string is on the page and work back from there or just rgrep the directory to find it. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Michael Wang wrote:> > That string is coming from somewhere. I''m guessing it''s a mistyped HTML > comment in one of your view files. Look at the HTML source of the page > after its been rendered by Rails to see where that string is on the page > and work back from there or just rgrep the directory to find it. > > > -- > Michael WangI don''t know where it is coming from but here is what''s being put into the db table from the log file: INSERT INTO comments (`date`, `profile_id`, `user_id`, `comment`) VALUES(''2007-07-27 20:48:55'', 1, 1, ''--- \n- |\n test 66\r\n\n'') So weird that stuff is literally coming out of no where. -- 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 -~----------~----~----~----~------~----~------~--~---
Scott Pn wrote:> Michael Wang wrote: >> >> That string is coming from somewhere. I''m guessing it''s a mistyped HTML >> comment in one of your view files. Look at the HTML source of the page >> after its been rendered by Rails to see where that string is on the page >> and work back from there or just rgrep the directory to find it. >> >> >> -- >> Michael Wang > > I don''t know where it is coming from but here is what''s being put into > the db table from the log file: > INSERT INTO comments (`date`, `profile_id`, `user_id`, `comment`) > VALUES(''2007-07-27 20:48:55'', 1, 1, ''--- \n- |\n test 66\r\n\n'') > > So weird that stuff is literally coming out of no where.I would suggest outputting the values of the info being sent into your controller / model. Also, check your form and do a ''view source'' just to make sure that it''s not ''special HTML'' formating. I.E. If you are hitting enter in the comments field to make a multi line comment, then that \r\n stuff wouldn''t be garbage, it would formatting code for the 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 -~----------~----~----~----~------~----~------~--~---
Scott Pn wrote:> <%= text_area :comment, params[:comment], :value => '''', :cols => > "55", :rows => "6" %><br />This should instead be text_area_tag. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James wrote:> Scott Pn wrote: > >> <%= text_area :comment, params[:comment], :value => '''', :cols => >> "55", :rows => "6" %><br /> > > This should instead be text_area_tag. > > -- > We develop, watch us RoR, in numbers too big to ignore.The text_area_tag had no effect on that input. This is really mindboggling. -- 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 -~----------~----~----~----~------~----~------~--~---
On 28-Jul-07, at 10:42 AM, Scott Pn wrote:> > Mark Reginald James wrote: >> Scott Pn wrote: >> >>> <%= text_area :comment, params[:comment], :value => '''', :cols => >>> "55", :rows => "6" %><br /> >> >> This should instead be text_area_tag. >> >> -- >> We develop, watch us RoR, in numbers too big to ignore. > > The text_area_tag had no effect on that input. This is really > mindboggling.Scoff, this is a key time to decouple. write some model(unit) tests. The tests ''should'' verify the results of a save. then write a controller(functional) spec. Will do the same, but test your controller layer. these 2 tests will be guaranteed to give you the symptoms you need to lick this bug (eww) dead. cheers, Jodi --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jodi Showers wrote:> On 28-Jul-07, at 10:42 AM, Scott Pn wrote: > >>> We develop, watch us RoR, in numbers too big to ignore. >> >> The text_area_tag had no effect on that input. This is really >> mindboggling. > > Scoff, this is a key time to decouple. > > write some model(unit) tests. The tests ''should'' verify the results > of a save. > > then write a controller(functional) spec. Will do the same, but test > your controller layer. > > these 2 tests will be guaranteed to give you the symptoms you need to > lick this bug (eww) dead. > > cheers, > JodiHow do I write tests for this. I looked around at the test stuff in the test folder, but I don''t what I am supposed to change to check the model and controller? -- 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 -~----------~----~----~----~------~----~------~--~---
On Fri, 2007-07-27 at 13:36 +0200, Scott Pn wrote:> Robby Russell wrote: > > Anything that is saved in the database would be going through any > > validations and filters that you put in place. > > > > Perhaps you could elaborate on what "junk" is. > > well it puts in --- - when I do a submit to the db.That looks like the start of a YAML document. Is the column serialised? Maybe AR is doing something funky because the column name is the same as the model name? -- Tore Darell <toredarell-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Scott Pn wrote:> Sorry, should have just posted some code in the first place. > > Here is the partial I am using to submit the comment. > (/partial/_add_comment.rhtml): > <div class="comment"> > <% form_tag :controller => ''comment'', :action => ''add_comment'' do %> > <label>Add a Comment:</comment><br /> > <%= text_area :comment, params[:comment], :value => '''', :cols => > "55", :rows => "6" %><br /> > <%= hidden_field :id, params[:id], :value => params[:id] %> > <%= hidden_field :user_id, params[:user_id], :value => > session[:user_id] %> > <%= submit_tag "Add Comment" %> > <% end %> > </div> >check 3rd line of div ... is that an errant close </comment> instead of </label> tag typo here or in actual code ? -- 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 -~----------~----~----~----~------~----~------~--~---
Scott Eckenrode wrote:> > check 3rd line of div ... is that an errant close </comment> instead of > </label> tag typo here or in actual code ?Yeah that was an error, but it wasn''t effecting the code that I had for the comment. And to Tore Darell or anyone really: What do you mean by AR? -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Scott, Scott Pn wrote:> And to Tore Darell or anyone really:Speaking for ''anyone'' ...;-)> What do you mean by AR?ActiveRecord Best regards, Bill --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---