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

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| %>

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 %>   <p><%= f.label :title %><br /><%= f.text_field :title %></p>   <p><%= f.label :description %><br /><%= f.rich_text_area :description %></p>   <p><%= f.submit 'Create' %></p> <% end %>

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

<script src="/javascripts/nicEdit.js?1294182055" type="text/javascript"></script> <script src="/javascripts/nicEditInit.js?1294182055" type="text/javascript"></script>

<html xmlns="http://www.w3.org/1999/xhtml&quot; xml:lang="en" lang="en"> <head> ... </head> <body>

<form action="/items" class="new_item" id="new_item" method="post"><div style="margin:0;padding:0;display:inline"><input name="authenticity_token" type="hidden" value="FCnWc8Q8vcadwBSnlhENQpmDjAECikKAK9ecOtFzjoI=" /></div>   <p>     <label for="item_title">Title</label><br />     <input id="item_title" name="item[title]" size="30" type="text" />   </p>   <p>     <label for="item_description">Description</label><br />     <textarea class=" simple_nicedit" cols="40" id="item_description" name="item[description]" rows="20"></textarea>   </p>   <p>     <input id="item_submit" name="commit" type="submit" value="Create" />   </p> </form> </body> </html>

thanks

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| %>

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 %> <p><%= f.label :title %><br /><%= f.text_field :title %></p> <p><%= f.label :description %><br /><%= f.rich_text_area :description %></p> <p><%= f.submit 'Create' %></p> <% 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.

Thanks

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 %> <p><%= f.label :title %><br /><%= f.text_field :title %></p> <p><%= f.label :description %><br /><%= f.rich_text_area :description %></p> <p><%= f.submit 'Create' %></p> <% end %>

Colin

I pasted the wrong code... Sorry.

It should be:

View Code:

<%= form_for(@item) do |f| %>   <%= f.error_messages %>   <p><%= f.label :title %><br /><%= f.text_field :title %></p>   <p><%= f.label :description %><br /><%= f.rich_text_area :description %></p>   <p><%= f.submit 'Create' %></p> <% end %>

I pasted the wrong code... Sorry.

It should be:

View Code:

<% form_for(@item) do |f| %>   <%= f.error_messages %>   <p><%= f.label :title %><br /><%= f.text_field :title %></p>   <p><%= f.label :description %><br /><%= f.rich_text_area :description %></p>   <p><%= f.submit 'Create' %></p> <% end %>

I don't know if I understood you correctly...

Any idea?

Thanks

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

Finally, I have used tinyMCE using the following link: https://github.com/kete/tiny_mce

It has a gem version too! :slight_smile:

Thanks!

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!

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 Law wrote in post #972629:

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

No, nested forms are not allowed in html. You can have multiple submit buttons in one form though.

Colin