Nicedit (rich text editor)

Hello, I’m trying to use Nicedit to improve my text_areas in some views
of my project.

I have installed jquery:
ruby script/plugin install git://github.com/aaronchi/jrails.git

nicEdit plugin:
ruby script/plugin install
git://github.com/sergio-fry/Simple-nicEdit.git

Add js in layout:
<%= javascript_include_tag ‘nicEdit’, ‘nicEditInit’ %>

Use it in form
<% form_for @item do |f| %>
<%= f.rich_text_area :description %>
<% end %>

I have no results in my views and no javascript errors appears (checked
with firebug).

Could someone tell me if I have skipped something?

Could someone recommend me other plugin or gem for this purpose?

Thanks

On 5 January 2011 10:21, Daniel O. [email protected] wrote:

Add js in layout:
<%= javascript_include_tag ‘nicEdit’, ‘nicEditInit’ %>

Use it in form
<% form_for @item do |f| %>

That should be <%= form_for…

I would have thought that looking at the html of the page (View >
Source in the browser) it would have been clear that this was not
generating anything.

Colin

Thanks for your response.

If I use <%= form_for… It breaks
ActionView::TemplateError (compile error
/home/fydserve/intraweb/app/views/items/new.html.erb:5: syntax error,
unexpected ‘)’
…(( form_for(@item) do |f| ).to_s); @output_buffer.concat
^
/home/fydserve/intraweb/app/views/items/new.html.erb:28: syntax error,
unexpected kENSURE, expecting ‘)’
/home/fydserve/intraweb/app/views/items/new.html.erb:30: syntax error,
unexpected kEND, expecting ‘)’) on line #5 of
app/views/items/new.html.erb:

View Code:

<%= form_for(@noticia) do |f| %>
<%= f.error_messages %>

<%= f.label :title %>
<%= f.text_field :title %>

<%= f.label :description %>
<%= f.rich_text_area :description %>

<%= f.submit 'Create' %>

<% end %>

HTML generated: It generates the script and atributte
class=“simple_nicedit” in textarea, but the view is showing normal
textarea.

...

Title

Description

thanks

On 5 January 2011 11:04, Daniel O. [email protected] wrote:

/home/fydserve/intraweb/app/views/items/new.html.erb:30: syntax error,
unexpected kEND, expecting ‘)’) on line #5 of
app/views/items/new.html.erb:

View Code:

<%= form_for(@noticia) do |f| %>

I don’t understand, the error above shows form_for(@item) so this
would not appear to be the code generating the error.

<%= f.error_messages %>

<%= f.label :title %>
<%= f.text_field :title %>

<%= f.label :description %>
<%= f.rich_text_area :description %>

<%= f.submit 'Create' %>

<% end %>

HTML generated: It generates the script and atributte
class=“simple_nicedit” in textarea, but the view is showing normal
textarea.

How is it generating html if you get a compile error?

Colin

I tried withe <%= form_form, as you told me, and I have compile error
(and nothing else of course)

If I use <% form_form, I have no compilation error and the html code.

I pasted wrong in the post…

Thanks

On 5 January 2011 11:25, Daniel O. [email protected] wrote:

I tried withe <%= form_form, as you told me, and I have compile error
(and nothing else of course)

Please quote the previous reply so the thread is easier to understand.

If I use <% form_form, I have no compilation error and the html code.

But the example you showed that did not error has <%= Quoting from
previous post:

<%= form_for(@noticia) do |f| %>
<%= f.error_messages %>

<%= f.label :title %>
<%= f.text_field :title %>

<%= f.label :description %>
<%= f.rich_text_area :description %>

<%= f.submit 'Create' %>

<% end %>

Colin

I pasted the wrong code… Sorry.

It should be:

View Code:

<% form_for(@item) do |f| %>
<%= f.error_messages %>

<%= f.label :title %>
<%= f.text_field :title %>

<%= f.label :description %>
<%= f.rich_text_area :description %>

<%= f.submit 'Create' %>

<% end %>

Finally, I have used tinyMCE using the following link:

It has a gem version too! :slight_smile:

Thanks!

On 5 January 2011 11:53, Daniel O. [email protected] wrote:

As I asked before, please include the appropriate bits of the previous
post in your message so that it makes sense. As it stands this
message will now make no sense to someone finding the thread in the
future.

I pasted the wrong code… Sorry.

It should be:

View Code:

<% form_for(@item) do |f| %>

It must be <%= form_for otherwise it will not work. If you cannot
get this to compile then that is the problem to find the solution to
first.

Colin

I don’t know if I understood you correctly…

Any idea?

Thanks

On 5 January 2011 13:40, Daniel O. [email protected] wrote:

Finally, I have used tinyMCE using the following link:
GitHub - kete/tiny_mce: A Ruby on Rails plugin (pre-Rails 3.1) that allows easy implementation of the TinyMCE editor into your applications.

It has a gem version too! :slight_smile:

Did you find that <%= form_for is now working for you?

Colin

As I asked before, please include the appropriate bits of the previous
post in your message so that it makes sense. As it stands this
message will now make no sense to someone finding the thread in the
future.

Ok, I didn’t know what you were meaning… :slight_smile:

Did you find that <%= form_for is now working for you?

No, I have no idea.

All my forms in edit and new views are <% form_for …

Should be <%= form_form inside <% form_for ?

I posted the compilation error and the html code I have with <% form_for
in previous messages. If is there something more I could show, please
tell me. I’m interesting to know why it didn’t work.

Thanks a lot!

On 5 January 2011 20:41, Daniel O. [email protected] wrote:

All my forms in edit and new views are <% form_for …

Should be <%= form_form inside <% form_for ?

I don’t understand what you mean by form_for inside form_for. Are
you using nested forms?

However I now find myself very confused. I have just done some
experiments and it seems that the = is not necessary. I am
particularly confused as in the last few weeks there have been at
least two occasions on which posters here have had problems which were
fixed by using <%=. But as I said I have just tried myself and <%
form_for seems to work perfectly ok. I do not understand this as I
thought erb only included the result of the expression in the html if
the = was present. Can someone with more knowledge of this comment
please?

Colin

Colin L. wrote in post #972629:

On 5 January 2011 20:41, Daniel O. [email protected] wrote:

All my forms in edit and new views are <% form_for …

Should be <%= form_form inside <% form_for ?

Is form_form actually what you’re typing? It should be form_for .

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Is form_form actually what you’re typing? It should be form_for .

No, sorry. Only bad typped when writing the post…

I don’t understand what you mean by form_for inside form_for. Are
you using nested forms?

<% form_for(@item) do |f| %>
<% form_for(@subitem) do |f| %>

… or something similar (Neither I don’t know if this is possible)

Thanks

On 5 January 2011 22:01, Daniel O. [email protected] wrote:

… or something similar (Neither I don’t know if this is possible)
No, nested forms are not allowed in html. You can have multiple
submit buttons in one form though.

Colin