Index of All Lessons

View Screencast (Quicktime)

Right-click on the button above and choose Save As to save file to your computer


Support the Course

There’s no charge for the course, but we greatly appreciate any donations.

Suggested donations:

  • One or two lessons: $5
  • Several lessons $10
  • Entire course: $25 – $50

We hope you’ve found the course to be valuable, and we appreciate any support you care to provide.


Sign Up Now!

If you aren’t already receiving our course lessons via email, sign up now to be sure you don’t miss anything.

Every few days, we’ll send you an email with a link to the next episode, plus a list of additional resources for advancing your knowledge.

There’s no cost and no obligation. And we’ll never share your email address with any third party.


We’ll send you the first lesson right away.


Want to help spread the word? We’d be grateful if you would include a link to the course in your blog, web site, or emails.

Looking for a Powerful Hosted CMS?

The authors of the Learning Rails course also offer a very powerful hosted content management system for web designers, which enables you to build sophisticated, database-driven sites without programming. This is a great alternative to building a custom Ruby on Rails site for those applications for which you just can't justify the cost of a custom solution.

To learn more, sign up for the free Learning Webvanta course on building database-driven web sites without programming.

Using Textile Markup, plus In-Place Editing with Ajax

comments

Goals

In this lesson we’re going to add two features to our content-management system: Textile markup and in-place editing. Both are, in principle, very simple to implement, thanks to a couple of Rails gems and plugins, as well as the Prototype and Scriptaculous JavaScript libraries. The reality turns out to be just as simple as we’d hope in the first example, and rather more complex in the second.

Please note that, while we’ve tried to make these notes complete, they aren’t the full tutorial; that’s in the screencast, which you can access via the link on the left.

Setup

We begin with the code with which we ended Lesson 12. These zip files contain the beginning and ending states of the code:

Using Textile markup

We don’t want our administrative users to have to enter HTML code, so we’ll use a simple markup language called Textile.

There’s two pieces of Ruby code we use to implement this. The first is the gem RedCloth, which you already have if you’re on Leopard. This is the code that translates Textile into HTML. The second is a Rails plugin called “acts_as_textiled”, which makes it trivially easy to add Textile markup to our content blocks.

Run “gem list” to see if you already have RedCloth. If not:

sudo gem install RedCloth

To add the plugin, open a terminal window at the root of your application and enter the following command:

script/plugin install svn://errtheblog.com/svn/plugins/acts_as_textiled

Add to the Page model:

acts_as_textiled :body

That’s it. This plugin is smart enough to automatically display the Textile markup source when you’re displaying the body in a form field, as we are in the admin pages, but to render it into HTML anywhere else you use the body.

You’ll need to stop and restart the server before the plugin will function.

Now you can edit any of the pages in the content management system, such as the admin page, to convert the markup to Textile. Note that the page list view shows the HTML created by RedCloth — that’s because the acts_as_textiled plugin automatically renders the Textile content into HTML anyplace except in a form field.

In-place editing

In-place editing is a common feature of modern web applications, and there’s good support for it built in to Prototype. There’s also a Rails helper that wraps the Prototype method so we don’t even have to touch the JavaScript code.

In Rails 1.2.x, the in-place editor helper was part of the framework. In Rails 2.0, however, it was split out as a plugin, in theory so it could be separately maintained. Unfortunately, it has not been maintained (as of this writing in early May 2008), so not only do we need to install the plug-in, we’re going to have to seek out and install a couple of patches before we have everything working.

Installing the plugin

Install the in_place_editing plugin by entering the following in a console at the root of your application:

script/plugin install http://svn.rubyonrails.org/rails/plugins/in_place_editing

Modifying our code to use the plugin

The readme file provides basic installation instructions. We need to make two small changes to our code. In the file views/viewer/show.html.erb, replace the one line of text that is now in that file with the following:

<%= in_place_editor_field :page, 'body' %>

Then add this line to the top of the class in controllers/viewer_controller.rb:

in_place_edit_for :page, :body

And finally, we need to tell our application to load the JavaScript libraries. Add to the head section in views/layouts/application.html.erb:

<%= javascript_include_tag :defaults %>

Now restart the server, since we’ve installed a plugin, and everything should work as before. But now, when you click on any page text, a little edit box comes up!

Try editing the text and click OK. Unfortunately, the save fails. To get a hint of what’s happening, view the page using Firefox with Firebug installed, and take a look at the console when you click the OK button. Scroll through the response and you’ll see that there’s an issue with the authenticity token.

The CSRF protection bug

The authenticity token is a feature added to Rails 2.0 to improve protection against cross-site request forgery (CSRF) attempts. Unfortunately, the team didn’t update the in-place editor plugin correspondingly, so this security feature trips it up.

Try a google search on “in place editing CSRF”. The first result is a ticket in the Rails Trac titled “in_place_editing plugin does not work with CSRF protection”! Look at the patch suggested; focus on the forgery protection, grab the four lines of code and paste them into vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb (see the screencast for details).

After adding these lines restart the server, reload the web page, click on some text to edit it, and click OK to save. Now it works!

A minor correction to the screencast discussion of the JavaScript code: in the audio, we referred to Ajax.InPlaceEditor as a Scriptaculous method. In fact, the Ajax object is part of the Prototype library, and the InPlaceEditor method is added by Scriptaculous.

Providing a larger text entry area

Next we want to provide a larger text entry field. Add the rows and columns options to the helper invocation:

<%= in_place_editor_field :page, 'body', {}, 
{:rows => 20, :cols => 80} %>

Refresh the browser, click on the text, and you should now see a decent size text area.

Displaying Textile source instead of HTML

Next problem: It is displaying the HTML markup, not the Textile source.

By default, the in_place_editor_field helper pulls the text to be edited from the page itself, not from the server, so naturally it sees the rendered HTML. To fix this, we need to set an option to tell it to fetch the source from the server, and then we need to create the controller code to respond to that request.

The option we need is called load_text_url. With this added to the helper invocation, we now have the following code in the view file:

<%= in_place_editor_field :page, 'body', {}, 
{:rows => 20, :cols => 80, 
 :load_text_url => {:controller => 'viewer', :action => 'get_unformatted_text', :id => @page.id}} %>

This tells the Scriptaculous method to make an XMLHttp request (the workhorse of Ajax applications) to retrieve the unformatted text.

Now we need to add the get_unformatted_text action to viewer_controller.rb:

def get_unformatted_text
  @page = Page.find(params[:id])
  render :text => @page.body(:source)
end

Take a look at the acts_as_textile readme to find the (:source) option that enables us to access the markup source, rather than the rendered HTML.

Reload the page, and it now displays Textile, just as we wanted.

Do we want visitors to be able to edit the site?

One small problem — unless our goal is to provide a wiki, we probably don’t want any visitor to be able to edit our site’s contents. So we need to use the in-place editor only if someone is logged in. Simple enough, just change the view code to:

<% if logged_in? %>

	<%= in_place_editor_field :page, 'body', {}, 
	{:rows => 20, :cols => 80, 
	 :load_text_url => {:controller => 'viewer', :action => 'get_unformatted_text', :id => @page.id}} %>

<% else %>

	<%= @page.body %>

<% end %>

Refresh the browser, and now in-place edit is available only to logged-in users.

Adding an external control

One more problem: in admin mode, we can’t access links on the page, because clicking anywhere in the page text takes us into edit mode. So our admin dashboard is now useless. This would also be a problem if any of the regular pages had links and we wanted to be be able to exercise them in admin mode.

Looking back at the in-place editor helper file, we see an option for externalControl, so let’s try that. Add one more option to our in_place_editor_field invocation:

<%= in_place_editor_field :page, 'body', {}, 
{:rows => 20, :cols => 80, :external_control => 'edit', 
 :load_text_url => {:controller => 'viewer', :action => 'get_unformatted_text', :id => @page.id}
} %>

And create an edit link at the top of the page to trigger this:

<a href='#' id='edit'>Edit This Page</a>

Refresh the page, and give the edit link a try. It works! Unfortunately, clicking on the text also triggers the edit control, so we need to somehow prevent that.

Making only the external control activate the edit mode

What we need is a way to have only the external control activate the in-place editor. Searching the web, we find confusing and contradictory results. But in the excellent book Prototype and Scriptaculous, we read up on the in-place editor options, and find a reference to an option externalControlOnly. Alas, the Rails helper doesn’t support this, so it’s back to patching the code.

In the helper, we find the line:

js_options['externalControl'] = "'#{options[:external_control]}'" if options[:external_control]

So let’s try duplicating this line in the helper, changing externalControl to externalControlOnly in the duplicate line, and then we change our view code to set this option to true:

<%= in_place_editor_field :page, 'body', {}, 
{:rows => 20, :cols => 80, :external_control => 'edit', :external_control_only => true,
 :load_text_url => {:controller => 'viewer', :action => 'get_unformatted_text', :id => @page.id}
} %>

And presto, now it behaves as we want!

Life in the open-source world is sometimes not as clean as we’d like it to be. Someone will no doubt update the in-place editor plugin soon, which will cut out more than half the effort of this exercise.

Coming Up

In our next lesson, we’re going to improve the navigation model for our content management system generated pages, so we can have sub-pages as well as main pages, and so the navigation button text can be different from the page title.


Add a Comment

Have a comment or question about this lesson? Add it here.






Comments on This Lesson

From: Davide Targa       Date: 11/16/09 09:19 AM

Subject: in place editing plugin

You can found the in place editing plugin here: http://github.com/rails/in_place_editing.git/

So the command to install it is: script/plugin install http://github.com/rails/in_place_editing.git/

The plugin is already fixed with the patch shown in the video. It works for me.

Hope this helps. Regards,

Davide

From: Davide Targa       Date: 11/16/09 09:15 AM

Subject: Text Rendering problems

I solved the problem of the displaying raw html in the pages by adding a line in the show action of the viewer controller. Now it looks like this: def show @page = Page.find_by_name(params[:name]) render :text => @page.body, :layout => true login_required if @page.admin? end

Hope this helps ;)

Regards,

Davide

From: Michael       Date: 11/04/09 01:51 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: Michael       Date: 11/04/09 01:50 PM

Subject: can't find in_place_editing plugin

None of the paths to in_place_editing in the lesson or in the previous comments seems to work. I found it listed on github, but ruby keeps telling me no such file or directory. Running OS X 10.6

From: cecille       Date: 09/29/09 12:40 AM

Subject: displaying raw html instead

i’m having problems regarding in_place_editing_field. it is displaying the raw html which is not quite right i think.

i’ve read some of the comments and i think some people experienced the same thing

other than that, this tutorial is amazing. i’m learning a lot. thanks!!!

From: Wayne Simacek       Date: 09/17/09 05:13 AM

Subject: Never got script/server to start

I got both the plugins installed from the git sites mentioned below and made the modifications, but I’m getting the same problems as Craig. I finally cheated and downloaded your code and everything started fine, but everything moving to git and newer versions has definately hosed your nice screencast.

Thanks for having a backup, so we can follow along though.

—Just a note, I’ve been waiting for Obamanomics to kick in and help me land a new gig (hopefully using rails.) When I do, I’ll be sure and throw you guys the monetary reward you deserve, as this is a great contribution and much appreciated.

Regards, Wayne

From: Craig       Date: 08/25/09 10:06 AM

Subject: Errors on script/server start after in-place editing plugin install

After installing the in-place editing plugin by

script/plugin install http://github.com/rails/in_place_editing.git/

I get a ton of errors with script/server start. Any ideas?

=> Booting Mongrel (use ‘script/server webrick’ to force WEBrick) => Rails application starting on http://0.0.0.0:3000 => Call with -d to detach => Ctrl-C to shutdown server

  • Starting Mongrel listening at 0.0.0.0:3000
  • Starting Rails with development environment… Exiting /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:376:in `new_constants_in’: You have a nil object when you didn’t expect it! (NoMethodError) You might have expected an instance of Array. The error occurred while evaluating nil.empty? from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:202:in `load_file’ from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:94:in `require_or_load’ from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:248:in `load_missing_constant’ from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing’ from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing’ from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:260:in `load_missing_constant’ from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing’ from /Users/craign/.gem/ruby/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:471:in `send’ … 40 levels… from /Library/Ruby/Gems/1.8/gems/rails-2.0.2/lib/commands/server.rb:39 from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require’ from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require’ from script/server:3

From: SJS       Date: 08/18/09 10:26 AM

Subject: O for 2 on this lesson

I’m really learning a lot with this series. Thank you for putting it together. However, This lesson has stumped me. I used the plugins from the code at the end of this lesson. With Acts_As_Textiled it installs correctly, I can see the files / code – but it never renders html – just h1. welcome to my home page. For in_place_editing, it also installs, creates the “edit this page” link, but when I edit it, it hangs saying “Loading…”. It will cancel out ok, but if I click OK it deletes what was there – so it’s editing the file, just not pulling in the source from the db. I’ve checked the posts, but no success. Any suggestions?

From: Bruno Moura       Date: 08/02/09 10:31 AM

Subject: Congratulations

This series is awesome, amazing! I’ll use this app for many others my future applications!

Thanks so much!

From: Gary       Date: 07/16/09 08:46 PM

Subject: acts_as_textiled

After a lot of searching I finally found a link for acts_as_textiled that works: http://svn.addictedtonew.com/public/apps/dead_as_a_doornail/groupie/vendor/plugins/acts_as_textiled

From: Jason Bray       Date: 07/07/09 03:48 PM

Subject: in_place_editing plugin

I’m going through these tuts for the first time and had trouble getting the in_place_editing plugin installed using the code provided above. I did find the correct plugin at GitHub though: git://github.com/rails/in_place_editing.git

I’m using Mac OS 10.5 though so I had to use this for the plugin link: http://github.com/rails/in_place_editing.git/

From: Michael Slater       Date: 07/04/09 10:05 AM

Subject: Using Liquid

James, the sort of interface you describe is definitely possible, but it is not simple to implement. We’ve been working on something similar for the hosted CMS that we’re building, Webvanta, and it’s been a major task. (We’re using a variant of the Radius tag language, rather than Liquid.)

You might want to consider using the Radiant CMS, built in Rails, instead of putting it all together yourself.

From: James Pellerano       Date: 07/02/09 07:47 PM

Subject: rich text and text

I am currently developing a site using pages stored in a database, instead of textile I am using YUI (Yahoo’s rich text editor), I saw a comment about using liquify as a way to insert partials into these pages, is there away to switch between using the rich text editor and plain text so i can use liquify and enter a partial to render a blog in one of these pages?

From: Braulio Carreno       Date: 06/08/09 12:30 PM

Subject: Displaying raw HTML

I was having the same problem as Heath and Mikael. Installed plugin from Juan Bernabó, git://github.com/jbernab/in_place_editing.git and the problem was solved. As he says, I didn’t have to touch my code.

Thank you Juan! Braulio.

From: JJ       Date: 05/27/09 02:31 PM

Subject: Displaying raw HTML

Hello. I am getting the same problem as Heath and Mikael Holmstrom.

When I am not logged in, the pages display correctly, with the correct headings and formatting (with the code <%= @page.body %> of the “else” part of the “show” view). But when I log in, the body of each page is displayed as raw HTML. with only the “edit_this_page” link displaying correctly. The editing and functional parts work correct as well. Its just not rendering the HTML when logged in. This leads me to believe that a change is needed in the testing part of the “show” view.

Any solution to this problem will be greatly appreciated. Keep up the good work!

Thanks, JJ

From: JJ       Date: 05/27/09 02:31 PM

Subject: Displaying raw HTML

Hello. I am getting the same problem as Heath and Mikael Holmstrom.

When I am not logged in, the pages display correctly, with the correct headings and formatting (with the code <%= @page.body %> of the “else” part of the “show” view). But when I log in, the body of each page is displayed as raw HTML. with only the “edit_this_page” link displaying correctly. The editing and functional parts work correct as well. Its just not rendering the HTML when logged in. This leads me to believe that a change is needed in the testing part of the “show” view.

Any solution to this problem will be greatly appreciated. Keep up the good work!

Thanks, JJ

From: Juan Bernabó       Date: 05/10/09 09:49 PM

Subject: in_place_editing plugin with support to acts_as_textiled

This plugin fork adds support to acts_as_textiled models and fields with no modification to the code. http://github.com/jbernab/in_place_editing/tree/master

Hope it works! Juan

From: Deen       Date: 04/27/09 08:33 PM

Subject: in place editing plugins

Hi, I think this is a problem with the latest rails. I’m not sure where to proceed actually. I also got a raw html tags when rendering (not yet editing) the body of the page. anyone has a clue to how to fix this?

From: Rushen Aly       Date: 04/09/09 04:10 PM

Subject: in_place_editing plugin shows raw html

When used in_place_editor_field and corresponding editing for returns raw html on the page. But page.body works well…What is the solution…

From: Mikael Holmstrom       Date: 04/08/09 06:01 AM

Subject: <%= in_place_editor_field :page, 'body' renders the text in readable HTML text

I think I’m experience the same problem as you Heath. If I use the code: <%= in_place_editor_field :page, ‘body’… it displays the body-text in Readable HTML, and when using the <%= @page.body %> it renders is correct i.e. as a Header and so on.

Any solutions? Cheers, Mikael

From: Marcos Cerutti       Date: 04/07/09 04:59 PM

Subject: Textile and editing in place

Hi there guys! first of all, thanks for such amazing tutorial!

Could someone help me with a little issue? After I started to use in place editor, the page content don’t get formatted, instead, I see things like

Title

.

Im using OS X 10.5.4

ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0] RedCloth (4.1.9, 3.0.4) mongrel (1.1.5, 1.1.4, 1.0.1) Rails 2.3.2

I downloaded in_place_editing from git://github.com/rails/in_place_editing.git, the unique source I’ve found. Guess what? When I changed the pluging folder by the one in app source code, it worked like a charm….

I know its working, but do you guys know why this happened?

Best regards, Marcos

From: Charlie Magee       Date: 04/03/09 11:41 PM

Subject: slight display error in previous message

It appears that Textile is creating the comments on these pages. In my previous comment the double hyphen in front of “force” was turned into an em dash. It should be – - force without the spaces. (Not sure what’s going to happen to my hyphens in this message after I submit, but you get the point.)

From: Charlie Magee       Date: 04/03/09 11:38 PM

Subject: in_place-editing git

The code to download in_place_editing that is provided on this page appears to be out of date. I found this at git and it worked. git://github.com/rails/in_place_editing.git If you already tried the version on this page, you might get the message that the plug-in is already installed. You’ll have to add —force at the end of the .git

From: Heath       Date: 03/26/09 04:48 PM

Subject: Previous Post

I figured it out. I removed all of the h (html safe) methods from the corresponding code. Code displays correctly.

From: Heath       Date: 03/25/09 12:51 PM

Subject: My System Info

Mac OSX 10.5.6, Ruby 1.8.7, Rails 2.2.2, RedCloth 4.1.9, Acts as Textiled Version: 0.3.

From: Heath       Date: 03/25/09 12:47 PM

Subject: Acts As Textiled displays raw HTML.

The problem I am having is in regard to, I believe, Acts as Textiled. Raw HTML is displayed while I am logged in. Everything works properly, I am able to edit pages via the Textiled shortcuts. The page displays rendered HTML perfectly after editing and selecting “ok” to save changes to the database. But, when I refresh the page, or navigate back to the edited page via site links, it displays raw HTML. Can anyone give my some insight as to what I may be missing or doing wrong?

Thanks, Heath

From: Kevin       Date: 02/07/09 06:35 PM

Subject: git with windows

MFF,

Yeah, I did the same thing. I spent HOURS trying to get it to install correctly from ruby at the command line. I visited many different sites and attempted to follow directions to get git running. It seems to work but the ruby command won’t get the files. Eventually (and probably not early enough) fatigue won over stubborn determination and I just decided to download and unzip it. I think this is how I will work with github for awhile…

If anyone has been able to get the ruby command running under windows VISTA I would really like to hear it.

From: Kevin       Date: 02/07/09 06:34 PM

Subject: git with windows

MFF,

Yeah, I did the same thing. I spent HOURS trying to get it to install correctly from ruby at the command line. I visited many different sites and attempted to follow directions to get git running. It seems to work but the ruby command won’t get the files. Eventually (and probably not early enough) fatigue won over stubborn determination and I just decided to download and unzip it. I think this is how I will work with github for awhile…

If anyone has been able to get the ruby command running under windows VISTA I would really like to hear it.

From: MFF       Date: 02/07/09 04:39 PM

Subject: Doh + acts_as_textiled maj. hassle

Kevin, thanks for the tip. I must be missing some sort of git/ruby/rails linkage. However, I wento to:

http://github.com/github/acts_as_textiled/tree/master

downloaded the zip and installed under vendor/plugins. Seems to work.

Thank for replying.

From: Kevin       Date: 02/07/09 09:48 AM

Subject: Doh!

MFF, see Steve Peterson’s comment below. Try installing git://github.com/lawrencepit/acts_as_textiled.git instead

From: Kevin       Date: 02/07/09 09:11 AM

Subject: I cannot connect to errtheblog.com either

MFF:

Getting the same answer. After beating my head against the wall for 3 hours I tried installing another SVN plugin – worked fine. I think something is wrong with the errtheblog.com svn server.

From: MFF       Date: 02/05/09 04:58 PM

Subject: Need acts_as_textiled... Help?

Would some kind soul help alivate this issue:

script/plugin install svn://errtheblog.com/svn/plugins/acts_as_textiled svn: Can’t connect to host ‘errtheblog.com’: Connection refused

Has anybody gotten around this? if so, how? the git alternate will not work for me.

From: Steve Peterson       Date: 12/21/08 07:34 PM

Subject: postscript to previous post

Sorry, some omitted but important details…

The error occured as soon as I launched the app after adding ‘acts_as_textiled :body’ to the page model. The key url found via google was

http://www.nabble.com/config.gem-dependencies-broken—td20770884.html

where the exact same symptom as mine is reported, with RedCloth. In this url is the link to the rails patched I referenced below.

From: Steve Peterson       Date: 12/21/08 07:34 PM

Subject: postscript to previous post

Sorry, some omitted but important details…

The error occured as soon as I launched the app after adding ‘acts_as_textiled :body’ to the page model. The key url found via google was

http://www.nabble.com/config.gem-dependencies-broken—td20770884.html

where the exact same symptom as mine is reported, with RedCloth. In this url is the link to the rails patched I referenced below.

From: Steve Peterson       Date: 12/21/08 07:20 PM

Subject: uninitialized constant Err::Acts::Textiled::ClassMethods::RedCloth

Need help from someone I think, since I am a rails newbe. Did googling and it looks like this is caused by a bug in Rails 2.2.2. Found a patch at http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1464. Using Rails 2.1.2 on windows. Updated to Rails 2.2.2 no sweat (gem update rails), tried to apply quick fix in C:\Ruby\lib\ruby\gems\1.8\gems\rails-2.2.2\lib\rails\gem_dependency.rb this line: return [] if specification.nil? but that did not work for me. Was going to apply patch with cygwin patch cmd, but after looking at it, it’s hard to imagine that it would work. Just curious, how come no one else is reporting this same issue? Also suggested solutions to this are most welcome!

Thanks

From: Oswaldo       Date: 12/21/08 11:15 AM

Subject: RedCloth gem installation

$ gem install RedCloth

NB: RedCloth is CamelCase, not lowercase. If you mistakenly do a gem install redcloth, you’ll get ERROR: could not find redcloth locally or in a repository.

From: Oswaldo       Date: 12/21/08 08:23 AM

Subject: act_as_textiled install url

Thanks Steve, it works

From: Steve Peterson       Date: 12/15/08 07:22 PM

Subject: svn: Can't connect to host 'errtheblog.com' no connection could be made because ...

I found a workaround for this…

at this site http://errtheblog.com/posts/12-actsastextiled I found a reference to this link to use instead: git://github.com/lawrencepit/acts_as_textiled.git

tis installed okay (preface with ruby script/plugin install)

From: Ryan       Date: 12/09/08 06:44 PM

Subject: Textile Href Not Working

I’m having the same problem as others wherein the textile markup for links (example) is being parsed as: "

so it would appear as:

"example":/example

Any suggestions for a fix?

From: Matt Platte       Date: 11/29/08 08:25 PM

Subject: Hacking Plugins

I enjoyed watching you solve the problems with the in-place editing plugin. Keeping it real…

From: MFF       Date: 11/27/08 10:52 AM

Subject: Textile Link (again)

I seem to have the same problem as BJ (below). I tried other measure such as downloading the app code at the end of Lesson 14 and replacing the ./acts_as_textiled directory in my tree from the (after) Lesson 14 tree.

The rendering is not working for the links. We get:

Body: “

Admin Dashboard

&#x000A;

"Page Admin":/pages

&#x000A;

"User Admin":/users

" Which does parse right. Anybody got any ideas what I could be doing wrong?

The Body Code looks like this: “h1. Admin Dashboard

Page Admin

User Admin"

Thanks, Michael

From: MFF       Date: 11/27/08 10:50 AM

Subject: Textile Link (again)

I seem to have the same problem as BJ (below). I tried other measure such as downloading the app code at the end of Lesson 14 and replacing the ./acts_as_textiled directory in my tree from the (after) Lesson 14 tree.

The rendering is not working for the links. We get:

Body:

Admin Dashboard

&#x000A;

"Page Admin":/pages

&#x000A;

"User Admin":/users

Which does parse right. Anybody got any ideas what I could be doing wrong?

The Body Code looks like this: h1. Admin Dashboard

Page Admin

User Admin

Thanks, Michael

From: Aaron Smith       Date: 11/06/08 09:12 AM

Subject: Re: textile

I had the same problems with link rendering but since I copied the acts_as_textiled source from the example code it work fine.

From: vvan       Date: 10/29/08 04:22 AM

Subject: textile

Hi there,

Has anyone solved the problem with textile? or RedCloth? The links do not work. Textile actually interprets quotes as html quotes;

"Pages Admin":/pages

I have actually tried uninstalling the latest RedCloth and installed 3.0.4 but no good! Any help would be appreciated. Cheers

From: Mike       Date: 10/24/08 11:25 AM

Subject: Installing Textile shows all html on my pages

After adding “acts_as_textiled :body” to my pages model, all the html shows on all the pages of my site. If I remove “acts_as_textiled :body”, the site looks fine again. Any ideas?

From: Chris       Date: 10/21/08 05:18 PM

Subject: svn acts_as_textiled

Hello all,

I just wanted to let you all know that the svn repository link for acts_as_textiled at agilewebdevelopment doesn’t work. I was able to do a search on github and found the corresponding plug-in.

so instead of script/plugin install svn://errtheblog.com/svn/plugins/acts_as_textiled

do this:

script/plugin install git://github.com/defunkt/acts_as_textiled.git

Assuming you have git, which you should if you’ve gone through setting up the git client at: http://www.buildingwebapps.com/articles/6433-setting-up-rails-on-leopard-mac

From: BJ       Date: 10/16/08 10:29 PM

Subject: Textile links

If you’re referring to the admin page, I don’t have the "p. " in the code. It is only the links that aren’t working. the markup for headers and other items seems to be working.

From: Michael Slater       Date: 10/16/08 02:28 PM

Subject: Textile problems

It looks like there is a change in behavior from RedCloth 3.0.4, which is what was current at the time we wrote this, and RedCloth 4.0.4, which is current today.

If you delete the "p. " at the start of each line (which isn’t needed anyway, and I’m not sure why it is there), then the links work in 4.0.4.

From: BJ       Date: 10/16/08 01:34 PM

Subject: Textile links

They don’t. I just see the textile mark up. There are no spaces. So I have the “Pages Admin” then the : and /pages. All put together.

From: Michael Slater       Date: 10/15/08 09:56 PM

Subject: Textile links

BJ, the links work fine for me. Are you sure you have no spaces around the colon? Does the default admin page show the links properly?

From: BJ       Date: 10/15/08 08:44 AM

Subject: Issues with Redcloth? - Mostly resolved (Repost)

Apparently the textile markup works here…Sorry. here is what I was trying to say..So I downloaded the code at the end of lesson 14 and that seems to have resolved everything except for the urls. When trying to edit the admin page using the textile markup for href it just displays the text, such as Page Admin:/pages. Is there something else I’m missing. A configuration?

From: BJ       Date: 10/15/08 08:43 AM

Subject: Issues with Redcloth? - Mostly resolved

So I downloaded the code at the end of lesson 14 and that seems to have resolved everything except for the urls. When trying to edit the admin page using the textile markup for href it just displays the text, such as -Page Admin-. Is there something else I’m missing. A configuration?

From: BJ       Date: 10/10/08 02:01 PM

Subject: Issues with RedCloth? Maybe - repost (sorry)

Thank you for these screencasts. i’m new to programming and have decided to learn RoR..this has been great.

I’m having issues with RedCloth, I believe. I’m on a Mac, 10.5.5. I’ve updated my installation of RedCloth and am on version 4.0.4. I’ve installed acts_as_textile plugin as well. However, I’m having two issues. First, in my pages.rb file if I put in:

acts_as_textiled :body

all my page titles lose their HTML formatting. They show up with the h1 /h1 tags around the text. However, if I change the pages.rb to show:

acts_as_textiled :body_text

then my page titles are correct. I’m not sure if this is an issue with a newer version of RedCloth or not.

Second issue is that when I edit pages in the page admin section I cannot use the textile markup. It is not being properly interpreted. I’m not sure if there is something I’m missing. Please help, as I’d like to move forward in this series.

Thanks.

B.J.

From: BJ       Date: 10/10/08 01:59 PM

Subject: Issues with RedCloth? Maybe

Thank you for these screencasts. i’m new to programming and have decided to learn RoR..this has been great.

I’m having issues with RedCloth, I believe. I’m on a Mac, 10.5.5. I’ve updated my installation of RedCloth and am on version 4.0.4. I’ve installed acts_as_textile plugin as well. However, I’m having two issues. First, in my pages.rb file if I put in:

acts_as_textiled :body

all my page titles lose their HTML formatting. They show up with the

tags around the text. However, if I change the pages.rb to show:

acts_as_textiled :body_text

then my page titles are correct. I’m not sure if this is an issue with a newer version of RedCloth or not.

Second issue is that when I edit pages in the page admin section I cannot use the textile markup. It is not being properly interpreted. I’m not sure if there is something I’m missing. Please help, as I’d like to move forward in this series.

Thanks.

B.J.

From: Ronen       Date: 09/29/08 09:46 AM

Subject: in place editing

Solved my problem.

I had to re-examine the Viewer\show.html.erb file. Now only logged in users can edit the pages.

From: Ronen       Date: 09/29/08 08:44 AM

Subject: in place editing

Thanks again for the great lessons Christopher and Michael. Where do I start troubleshooting when any user can highlight and change the :body area in my pages? This is happening without having to log in.

Thanks for the help.

From: Christopher Haupt       Date: 09/25/08 08:56 AM

Subject: RE: TinyMCE and in-place editing

Marius: Googling around with the keywords “tinymce rails inplace editing” shows that people have tried a variety of things over time. One of the better leads I’ve found is this AJAX in-place rich editor.

If I find something easier I’ll post it on buildingwebapps.com’s in-place editor category. Please let us know if you find something too.

-Christopher

From: Marius       Date: 09/24/08 01:58 PM

Subject: TinyMCE WYSIWYG Text Editor in the In-place editing

Hi Christopher,

I was wondering how to implement the TinyMCE WYSIWYG Text Editor (or any other HTML Editor or Rich Text Editor) in the In-place editing in this lesson? any tips

Thanks in advance, Marius

From: Jose Ignacio       Date: 09/20/08 02:50 PM

Subject: Thanks so much! please don't make it faster - this is fast enough

Just wanted to thank you guys again for the great work. This screencasts are much better than any book. I feel that this lesson is as real as it gets.

I can see, that what I do is not so unorthodox after-all, a book could never share as much information as you have in here (so fast). Not only, I learned how to use RoR but also programming procedures and debugging steps for this framework, patching helpers, etc, etc. I come from web-design(ie drawing) and after years away from programming ©, I am very excited about learning RoR in this way.

Thank you so much for keeping it simple and organized!

From: David Petty       Date: 09/04/08 01:59 PM

Subject: jQuery in place editing feature works better

Chris, and Michael,

I’ve been using jQuery in my php development for work and wanted to check it out in Rails. I installed the plugin for jRails that included the latest version of the jquery.js before starting this lesson. When trying to follow this lesson with the jrails plugin installed I could not use the in place editor, so I install the jrails_in_place_editing plugin. Once that was done I loaded the app and tried to edit it. I worked great. It allowed editing in textile and it saved the changed data with out a problem. with no additional code.

If you’d like more info on this let me know?

Thanks, Dave

From: Gregory       Date: 08/16/08 04:37 AM

Subject: set_page_body method

Hello,

Thanks for your great work, your tutorials are really great!

I’ve got a question concerning the following method:

def set_page_body @page = Page.find(params[:id]) @page.update_attribute(:body, params[:value]) render :text => @page.body end

I’ve found this method in the ViewerController, in the example app code as of the end of Lesson 14. But as far as I remember it was not explained during your screencast.

I’ve found in development.log the following: Processing ViewerController#set_page_body (for 127.0.0.1 at 2008-08-16 12:44:54) [POST] [….]

which means the application tries to run this method. My version of the application was working ok (i.e. in place editing was working correctly) despite of the fact set_page_body was not implemented.

Could you explain the role of this method?

Thanks a lot Gregory.

From: Christopher Haupt       Date: 07/25/08 10:51 AM

Subject: RE: latest inplace editing plugin

[A comment by “James” got redirected in our recent data center move, he wrote:]

The following is the most recent in_place_editing plugin with the latest bug fixes but it’s on GIT and not SVN. So you’ll need to install GIT first then do the following:

ruby script/plugin install git://github.com/jfernandez/in_place_editing.git

From: Michael Slater       Date: 06/29/08 10:01 AM

Subject: Partials in CMS

Walter, this is beyond the scope of the writeup we’ve done here. To render a partial controlled by text in the CMS, that text would have to be executed. You can modify the CMS text rendering to execute ERb (embedded Ruby) in the text block, but that opens up your entire database to anyone who can enter text into the CMS.

There are safe alternatives, such as the Liquid markup language. You can also add custom markup definitions to Textile, so a certain string would trigger generation of a certain partial.

From: Walter       Date: 06/29/08 08:27 AM

Subject: how to insert partial into textile edit?

how do you insert a partial inside the textile markup? I want a partial to load in with the homepage /home menu, otherwise if using the redirect system mentioned later, I end up with two homepages; one that loads from @pages and the other that reacts to the menu click as http://localhost:3000/posts/list?name=home . So how would I add /posts/list?name=home as a partial to /home ? Thus merging both CMS systems.

From: john trenouth       Date: 06/05/08 03:13 AM

Subject: In place editing within loops

Trying this within a loop (like if you have a list of items and you want each to be editable in place) gave me error after error.

I fixed it by adding:

<% @item = item %>

before:

<% in_place_editor_field :item, ‘todo’ %>

From: Christopher Haupt       Date: 06/03/08 01:47 AM

Subject: RE: Answering my own question

Ben, thanks for the comments.

Yes, we need to make the Subversion (and now git too) requirements more clear. In the series of articles I wrote on settiing up your dev environment I walk folks through setting up Subversion, but don’t make it as clear as I could that you need the tool for more than just putting your own code in source code control.

Now that git is becoming the primary revision control tool of choice, and many plugins are moving to that tool, we will need to update our articles in the future to cover this requirement. It will also be important for people to get to Rails 2.1 to make using git easier (via tools like script/plugin).

From: Ben       Date: 06/03/08 12:07 AM

Subject: Answering my own question

OK, so I overlooked the fact that Windows doesn’t have Subversion installed by default. Maybe that should be mentioned, since these tutorials are aimed at newbies… Maybe it was – if so I missed it.

Anyway, I know I’m not the only one that would have been held up here. There are some tutorials stepping through how to install Subversion on Windows, but there is also a GREAT one click installer that walks you through the process: http://blog.briankohrs.com/2005/09/06/less-than-mere-moments-installation-of-subversion/

Very painless.

P.S. Great series incidentally – far superior to anything else I’ve found for beginners to Rails. If you could just add a note for Windows users re: Subversion, it would be even better :D

From: Ben       Date: 06/02/08 03:10 AM

Subject: Cannot install acts_as_textiled plugin

It’s been driving me mad, but I can’t work out why it doesn’t work. Navigated to the application directory, and used: ruby script/plugin install svn://errtheblog.com/svn/plugins/acts_as_textiled

The terminal doesn’t show any installation, but doesn’t throw any errors. But nothing new appears under vendor>plugins.

Can anyone shed some light on what I’m doing wrong?

From: Erik       Date: 05/28/08 01:54 AM

Subject: Keep up the Great Work!

I am thoroughly enjoying these professionally-produced lessons that go into appropriate amounts of detail and don’t overwhelm with information. It is challenging learning to understand the MVC model, since it is quite different than other frameworks out there, but I feel like I’m getting it. I listened to all the audiocasts so far but I definitely have to say the video ones are much more superior in their effectiveness. Being able to see real code and environments is paramount to understanding.

I am an experienced web developer but have to say that learning new languages is always a challenge. I would suggest going into some details about the syntax of Ruby would be helpful as well in context of the lessons, for example, explaining what a kind of object a particular value is, and where it is derived from. I find that the hardest thing to understand are the linkages between the auto-generated code and the new code that is added. I guess it just takes time to understand what certain code is to be able to remember methods and objects for customizing your own code.

Great work and can’t wait for more!

From: Kenn       Date: 05/24/08 04:29 AM

Subject: Waking up

I’m impressed by your decision to handle/deal with the “sub-lesson” about open source issues and the CSRF bug example. Introducing a need to Google for information while stepping through a novice geared tutorial was very real world dimensional.

One of my biggest AHA moments about “learning programming” was accepting “typos” with written instruction. Your screen cast note “while we’ve tried to make these notes complete, they aren’€™t the full tutorial” is why your written lessons w/screen cast are so engaging!

From: Christopher Haupt       Date: 05/19/08 04:41 AM

Subject: RE: Painfully Slow

Thanks for the comment, though we prefer to keep the discourse respectful. This series of ‘casts on LearningRails is a free contribution to the community dedicated to new learners of Ruby and Ruby on Rails. Many of our audience members are new to web development or these technologies, so we are going at a steady, but introductory, pace as we explore facets of Rails. There are other good information sources out there. Check out the book lists and articles at BuildingWebApps.com or Google around for more advanced materials that may be more your speed.

From: alan       Date: 05/18/08 04:21 PM

Subject: Painfully Slow

You should really give people some credit, we’re not all retards. By the time you get anywhere usefull/practical/relevant, we’ll all be using some other framework already.

From: Chris P       Date: 05/18/08 02:35 AM

Subject: Outstanding

The best screencasts I’ve seen. I’ve never learnt so much so fast :)

From: Machipsi       Date: 05/14/08 11:25 PM

Subject: Awsome

I look forward to these screencasts every week. You guys are doing a great job.

From: Owen madden       Date: 05/13/08 08:16 AM

Subject: Screencast

Wondefull – easy to follow as alwasy step by step – Thanks

From: Ray Rogers       Date: 05/12/08 12:19 AM

Subject: Wrong cut and paste

app_root$ script/plugin install svn://errtheblog.com/svn/plugins/acts_as_textiled

From: Ray Rogers       Date: 05/12/08 12:14 AM

Subject: Tried to install acts_as_textiled

i run the following code; app_root$ ruby script/plugin install http://svn.rubyonrails.org/rails/plugins/in_place_editing I get this error: sh: svn: not found

 

Sponsored By

New Relic Rails Performance Monitoring