Hi: I am using FCKeditor in one of my form, when i copy and paste something into it using WordPaste, it appends few newlines at the beginning and at the end. How can i strip just those \n without effecting the inbetween newlines and the formatting. TIA, Priya -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
rajeevsharma86
2010-Aug-19 04:43 UTC
Re: Removing just leading and trailing newline characters
you may use strip http://ruby-doc.org/core/classes/String.src/M000820.html or any else as required . On Thu, Aug 19, 2010 at 9:59 AM, Priya Saini <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi: > > I am using FCKeditor in one of my form, when i copy and paste something > into it using WordPaste, it appends few newlines at the beginning and at > the end. > How can i strip just those \n without effecting the inbetween newlines > and the formatting. > > > TIA, > Priya > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks: Rajeev sharma -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Priya Saini
2010-Aug-19 04:52 UTC
Re: Removing just leading and trailing newline characters
Thanks for ur instant reply Rajeev. On irb strip is working exactly the way i want but inside code it isn''t solving the purpose. rajeevsharma86 wrote:> you may use strip > > http://ruby-doc.org/core/classes/String.src/M000820.html > or any else as required . > > On Thu, Aug 19, 2010 at 9:59 AM, Priya Saini <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> Priya >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > -- > Thanks: > Rajeev sharma-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
rajeevsharma86
2010-Aug-19 04:58 UTC
Re: Re: Removing just leading and trailing newline characters
Explain yours purpose here
put some lines of code i will tell you the way
do something in model
before_save : strip_description
def strip_description
unless !self.description.nil?
self.description = self.description.strip # or whatever please
check that how to
# implement strip on string
end
Still having issue rajeevsharma86-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org add me
On Thu, Aug 19, 2010 at 10:22 AM, Priya Saini
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> Thanks for ur instant reply Rajeev. On irb strip is working exactly the
> way i want but inside code it isn''t solving the purpose.
>
> rajeevsharma86 wrote:
> > you may use strip
> >
> > http://ruby-doc.org/core/classes/String.src/M000820.html
> > or any else as required .
> >
> > On Thu, Aug 19, 2010 at 9:59 AM, Priya Saini
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
> > wrote:
> >
> >> Priya
> >> For more options, visit this group at
> >> http://groups.google.com/group/rubyonrails-talk?hl=en.
> >>
> >>
> >
> >
> > --
> > Thanks:
> > Rajeev sharma
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
Thanks:
Rajeev sharma
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Priya Saini
2010-Aug-19 05:08 UTC
Re: Re: Removing just leading and trailing newline characters
Hi: Its a simple form to create a job. FCKeditor has been placed with the name job[description]. At the create event, it assigns the value to @job.description. I was trying to strip it before saving like: @job.description = params[:job][:description].strip, but it isnt solving the purpose. In the db, the description field shows a number of blank lines at the beginning and end. rajeevsharma86 wrote:> Explain yours purpose here > > put some lines of code i will tell you the way > do something in model > before_save : strip_description > > def strip_description > > unless !self.description.nil? > self.description = self.description.strip # or whatever please > check that how to > # implement strip on string > end > > > Still having issue rajeevsharma86-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org add me > > On Thu, Aug 19, 2010 at 10:22 AM, Priya Saini <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> > wrote: >> > Rajeev sharma >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> > > > -- > Thanks: > Rajeev sharma-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
rajeevsharma86
2010-Aug-19 05:23 UTC
Re: Re: Re: Removing just leading and trailing newline characters
try this
*validate :striped_descriptions
def striped_descriptions
# striping_description
unless self.description.nil?
logger.debug ''self.description before strip''
logger.debug self.description
striped_description = (self.description).strip
self.description = striped_description
logger.debug ''self.description after strip''
logger.debug self.description
end
end
*
*or*
try this
*before_save :striped_descriptions
def striped_descriptions
# striping_description
unless self.description.nil?
logger.debug ''self.description before strip''
logger.debug self.description
striped_description = (self.description).strip
self.description = striped_description
logger.debug ''self.description after strip''
logger.debug self.description
end
end
*
On Thu, Aug 19, 2010 at 10:38 AM, Priya Saini
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:
> Hi:
>
> Its a simple form to create a job. FCKeditor has been placed with the
> name job[description].
> At the create event, it assigns the value to @job.description.
> I was trying to strip it before saving like:
> @job.description = params[:job][:description].strip, but it isnt solving
> the purpose.
>
> In the db, the description field shows a number of blank lines at the
> beginning and end.
>
> rajeevsharma86 wrote:
> > Explain yours purpose here
> >
> > put some lines of code i will tell you the way
> > do something in model
> > before_save : strip_description
> >
> > def strip_description
> >
> > unless !self.description.nil?
> > self.description = self.description.strip # or whatever
please
> > check that how to
> > # implement strip on string
> > end
> >
> >
> > Still having issue
rajeevsharma86-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org add me
> >
> > On Thu, Aug 19, 2010 at 10:22 AM, Priya Saini
<lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
> > wrote:
> >
> >> > wrote:
> >> > Rajeev sharma
> >> .
> >> For more options, visit this group at
> >> http://groups.google.com/group/rubyonrails-talk?hl=en.
> >>
> >>
> >
> >
> > --
> > Thanks:
> > Rajeev sharma
>
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
>
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>
--
Thanks:
Rajeev sharma
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Priya Saini
2010-Aug-19 06:06 UTC
Re: Re: Re: Removing just leading and trailing newline characters
Didnt help. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Priya Saini
2010-Aug-19 06:17 UTC
Re: Re: Re: Removing just leading and trailing newline characters
Hey thanks Rajeev.. It worked.. Was doing a silly mistake.. Priya Saini wrote:> Didnt help.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
rajeevsharma86
2010-Aug-19 06:21 UTC
Re: Re: Re: Re: Removing just leading and trailing newline characters
cheers :) On Thu, Aug 19, 2010 at 11:47 AM, Priya Saini <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hey thanks Rajeev.. It worked.. > Was doing a silly mistake.. > > Priya Saini wrote: > > Didnt help. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Thanks: Rajeev sharma -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-19 12:08 UTC
Re: Removing just leading and trailing newline characters
Priya Saini wrote:> Hi: > > I am using FCKeditor in one of my form, when i copy and paste something > into it using WordPaste, it appends few newlines at the beginning and at > the end. > How can i strip just those \n without effecting the inbetween newlines > and the formatting. >This is probably best done with a regular expression.> > TIA, > PriyaBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeffrey L. Taylor
2010-Aug-19 16:42 UTC
Re: Re: Removing just leading and trailing newline characters
Quoting Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>:> Priya Saini wrote: > > Hi: > > > > I am using FCKeditor in one of my form, when i copy and paste something > > into it using WordPaste, it appends few newlines at the beginning and at > > the end. > > How can i strip just those \n without effecting the inbetween newlines > > and the formatting. > > > > This is probably best done with a regular expression. >Isn''t this just what String#strip does? Jeffrey -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Aug-19 19:19 UTC
Re: Re: Removing just leading and trailing newline characters
Jeffrey L. Taylor wrote:> Quoting Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>: >> This is probably best done with a regular expression. >> > > Isn''t this just what String#strip does?No. Strip removes all whitespace, not just newlines.> > JeffreyBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org Sent from my iPhone -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.