Table of Contents

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.

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.

Lesson 13
Admin Pages

comments Bookmark and Share

Goals

In this lesson, we implement the actual administrative dashboard using improvements we make to the mini-CMS we are building. We finish up with an improvement to our navigation code so we can build the tabbed interface more dynamically.

Setup

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

Admin Pages

Of course, it is tiresome to keep typing the URLs manually to get to our administrative pages. Let’s create an admin dashboard page that connects us to these sub-pages. Let’s also make the admin page easy to reach when we are appropriately logged in.

Make the Admin page attribute

If we are going to use our baby-CMS to implement this page, what is missing? We need to know when a page is an admin type page so we can protect it properly.

Make a migration to add an admin attribute to pages, and then set some default values in the migration to keep things tidy.

class AddAdminPageAttribute < ActiveRecord::Migration
  def self.up
    add_column :pages, :admin, :boolean
    
    @pages = Page.find(:all)
    @pages.each do |page|
      page.update_attribute(:admin, false)
    end
    
  end

  def self.down
    remove_column :pages, :admin
  end
end

Now, we need to update the Page Admin html so we can see/edit the new admin attribute:

First, index.html.erb gets a couple of new table entries:

<h1>Listing pages</h1>

<table>
  <tr>
    <th>Name</th>
    <th>Title</th>
    <th>Body</th>
    <th>Admin?</th>
  </tr>

<% for page in @pages %>
  <tr>
    <td><%=h page.name %></td>
    <td><%=h page.title %></td>
    <td><%=h page.body %></td>
    <td><%= page.admin? ? "TRUE" : "FALSE" %></td>
    <td><%= link_to 'Show', page %></td>
    <td><%= link_to 'Edit', edit_page_path(page) %></td>
    <td><%= link_to 'Destroy', page, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>

<br />

<%= link_to 'New page', new_page_path %>

Then add a snippet to show.html.erb to see the Admin value:

<p>
   <b>Admin?</b><br />
   <%= @page.admin? ? "TRUE" : "FALSE" %>
</p>

Update both edit.html.erb and new.html.erb with a snippet to use a check box for the state of the admin attribute (put this in before the submit):

<p>
  <b>Admin?</b><br />
  <%= f.check_box :admin %>
</p>

We should be all set. Check it out and create a page with the admin bit set. Can you see it when you are logged in? What about when you aren’t? Oops!

Update the viewer controller to handle special pages

Of course, we don’t filter in anyway for admin pages, so anyone can see a page marked with the Admin bit. Let’s fix that by protecting admin viewable pages by updating the viewer controller:

def show
  @page = Page.find_by_name(params[:name])
  login_required if @page.admin?
end

We are leveraging the login_required function provided to us by the restful_authentication plugin. If the requested page has the admin value set to true, we’ll check to see if the user is logged in with login_required.

Add an admin dashboard page in the DB

Finally, we can create a page using the mini-CMS’ Page Admin. Make one now and we’ll call it “admin”. Make the page contents as follows:

	<a href="/pages">"Page Admin"</a>
	<br>
	<a href="/users">"User Admin"</a>

Test it. Check it logged in and logged out. It works!

Make layout dynamic

It is getting really tiresome to keep updating our simple navigator, since we need to access the admin pages regularly, let’s take this opportunity to make a new tab appear for each page automatically.

Update the application layout to support rendering tabs dynamically. Here is the new navbar div:

<div id='navbar'>
	<ul>
		<% @tabs.each do |page| -%>
			<li><%= link_to page.title, view_page_path(page.name) %></li>
		<% end -%>
		<li><% if logged_in? %>
					<%= link_to "Log Out", logout_path %>
				<% else %>
					<%= link_to "Log In", login_path %>
				<% end %>
		</li>
	</ul>
<div>

We need to add a before_filter to application.rb to load up pages into that @tabs variable:

before_filter :get_pages_for_tabs

def get_pages_for_tabs
  if logged_in?
    @tabs = Page.find(:all)
  else
    @tabs = Page.find(:all, :conditions => ["admin != ?", true])
  end
end

This won’t deal well with lots of pages, so in the future we’ll improve this solution with the notion of page groups, sub-navigation, and other tricks.

Wrapping up

Try out the new navigation at localhost:3000. You may want to tweak the titles of the pages to make the tabs look better. We are reusing the same data as is used for the page titles in the title bar of the browser. A better solution over time may be to add a separate attribute so we can keep SEO friendly titles.

We finally have support for “administrative” pages in our simple CMS, so we can create the dashboard using our own technology!

Coming up

Next time, we’ll add the ability to use Textile markup in our CMS pages (via a plugin) and start playing with AJAX to make the UI a little easier to use.


Add Your Comments

(not published)

Reader Comments

32 comments

undefined method admin

From: Lyyza, 10/21/10 12:07 AM

i do know why..I alredy follow the steps but when i want to login as a admin...the message display..login incorrect...so i add admin as a new user...then when 1 want to run it....the errormsg display as shown below: NoMethodError in Pages#index Showing app/views/pages/index.html.erb where line #17 raised: undefined method `admin?' for # Extracted source (around line #17): 14: <%=h page.name %> 15: <%=h page.title %> 16: <%=h page.body %> 17: <%= page.admin? ? "TRUE" : "FALSE" %> 18: <%= link_to 'Show', page %> 19: <%= link_to 'Edit', edit_page_path(page) %> 20: <%= link_to 'Destroy', page, :confirm => 'Are you sure?', :method => :delete %>

admin user

From: angelo, 06/19/10 01:32 PM

whats the point of having a admin user if every user can log in as admin? well anyway great screencasts! thanks.

where to put in link_to page.title

From: Liam, 11/12/09 02:18 PM

I have some css that requires a tag in the navbar "tabs" - could you please explain where to put this in your code that dynamically generates the tabs (needless to say had it working when doing the manual hard-coded way!)... <% @tabs.each do |page| -%>

  • <%= link_to page.title, view_page_path(page.name) %>
  • <% end -%> I have tried to wrap it around page.title to no avail many thanks for a fantastic series

    Slightly Disappointed

    From: SwizzleCode, 10/06/09 12:18 AM

    As a newbie to Ruby on Rails, I've enjoyed and learned quite a bit from your tutorials, but I must say that I'm slightly disappointed that the shownotes and the downloadable code haven't been corrected to coincide with the screencast. I, like many copy your code from the shownotes or download and paste it when you have long blocks of new code that you yourself do the same ("so you don't have to wait for me to type this, I'll get from the clipboard"). Is it really that difficult to correct the name of the migration so newbs like me don't have to take time to see where we screwed up? Luckily, I caught the issue relatively quickly, but why should we have to debug these types of problems? Do I now have to make it a practice to scroll to the bottom of the shownotes first and see what errors others have encountered before I even start a lesson? Thanks for listening.

    Need to close the Navbar div

    From: Wayne Simacek, 09/17/09 03:33 AM

    Small thing....but you need to close the Navbar div. Thanks again for the lesson. Wayne

    rake db:migrate errors

    From: Charlie Magee, 04/08/09 04:20 PM

    I've been getting the same rake error as "fil" at the bottom of this comments page: Error is: rake aborted! uninitialized constant AddAdminPageAttributeToPages I've had intermittent problems on several other of the Lessons as well and I think I tracked down what I'm doing wrong. My problem is that I have been downloading the app code supplied on the lesson pages and using those to copy and paste into my code files because there's no way I want to type all that when I can just listen to Michael and Christopher explain. However, the app files don't always match what they're telling us to do onscreen! At least not in this lesson. In this lesson we're told to make a migration called AddAdminPageAttributeToPages. But the migration in the downloaded lesson is called AddAdminPageAttribute. So I wasn't paying enough attention, so after pasting everything in the .rb file then my rake didn't match the code anymore. I hope this helps. Charlie Magee

    rake db:migrate errors

    From: Charles Ford, 01/04/09 11:40 AM

    Micheal and Christopher, You guys have produced an excellent and very professional set of tutorials. 'Learning Rails' is a sophisticated demonstration. Thank you for all the work you've put into the product. I'm new to Ruby on Rails and am enjoying 'Learning Rails' very much. I'm running Ruby 1.8.7p72 and Rails 2.2.2 on a Mac and have encountered only one problem that took any real effort to solve. I thought I'd pass along my work-around in case it could help someone else who runs into the same frustration. Of course, there's probably a simple explanation and fix as to the error I got, but, being new to the whole Rails concept and community, I have no idea what it is. (I tried posting this solution earlier, before I realized the message would be going through TextTile, so the earlier message looked pretty garbled. Hence, the double posting.) Again, thanks for the large contribution you've put forth. Charles h3. add_column migration error Tip: export sqlite database, convert and import into mysql A) Export sqlite database: cd app_root sqlite3 db/development.sqlite3 .dump .quit >> export.sqlite.sql B) This dump file should be modified before the mysql import: -Replace ” (double-quotes) with ` (grave accent) -Remove “BEGIN TRANSACTION;”, “COMMIT;”, and all lines related to “sqlite_sequence” -Replace “autoincrement” with “auto_increment” C) Save file as import.mysql.sql D) Run the import into mysql : (assumes database has been created) mysql -uroot -p myapp_development < import.mysql.sql E) Edit the database.yml file : adapter: mysql username: root password: =your mysql password= host: 127.0.0.1

    rake db:migrate errors

    From: Charles Ford, 01/02/09 09:38 AM

    Lesson 13 Step: AddAdminPageAttributeToPages Problem: rake db:migrate errors Solution: After trying several things and searching for a solution, I decided to switch the database from SQLite3 to MySQL. Platform: Mac OS X 4.11 Ruby 1.8.7p27 Rails 2.2.2 Export sqlite database, convert and import into mysql 1) Export sqlite database: # cd # sqlite3 db/development.sqlite3 .dump .quit >> export.sqlite.sql 2) This dump file should be modified before the mysql import: - Replace " (double-quotes) with ` (grave accent) - Remove "BEGIN TRANSACTION;" "COMMIT;", and lines related to "sqlite_sequence" - Replace "autoincrement" with "auto_increment" 3) Save file as import.mysql.sql 4) Run the import into mysql : mysql -uroot -p myapp_development < import.mysql.sql I got errors when importing into MySQL. Since the database is so small, I used the CREATE

    and CREATE lines as an SQL Query. That worked. Then, since the database is so small, I just inserted the data into the tables manually. The fourth migration file ( in my case: app>db>migrate>20090102062925_add_admin_page_attribute_to_pages.rb ) was still intact from following the tutorial. -- the prefix '20090102062925_' shows I'm running a Mac as it's a timestamp, not a sequentially ordered number -- Next, I edited the config>database.yml file, replacing everything having to do with SQLite3 with these lines: development: adapter: mysql database: myapp_development username: root password: host: localhost After exporting the SQLite database, importing the MySQL database, verifying the new data, verifying the migration files, and editing the database.yml file, I went back to the terminal command line and entered the migration command: rake db:migration It worked like a charm and I'm back in business. Hope this helps...

    Layout is different than shown in screencast

    From: Dale Bremer, 12/07/08 01:36 PM

    I believe I found the layout problem: In layout/application.html.erb you have a line 26 which seems to be an unmatched

    . I commented this line and added a to the line before line 35. This did not help with the login dialog that appears with IE (I did not expect it to anyway). Thanks, Dale

    Layout is different than shown in screencast

    From: Dale Bremer, 12/07/08 12:28 PM

    In firefox 3.0.4 the header is centered the login form is left most and the footer goes across the bottom. In IE 6.0.2 it is all leftmost but the header stops about 3/4 across (1440x900 display) and the footer is fully across. Also in IE a windows login dialog pops up first while this does not happen in FF. I am pretty new to Rails, Ruby, and even NetBeans but I feel I have copied the code and set it up correctly. Thoughts? PS: Good set of tutorials. I will rate highly in iTunes shortly.

    Elegant solution?

    From: Dale Botha, 11/05/08 02:57 PM

    Hi Michael and Christopher! Awesome screencasts! I wanted to make those admin pages available to that admin user and I did it this way: def get_pages_for_navigation @user = current_user if @user != nil if @user.login == "admin" @tabs = Page.find(:all) else @tabs = Page.find(:all, :conditions => ["admin == ?", false]) end else @tabs = Page.find(:all, :conditions => ["admin == ?", false]) end end Is this a good solution or is there another way you could suggest that would be better! Thanks again! I'll donate soon....when I'm a bit more flush! Dale

    migrate

    From: sharon, 08/25/08 06:44 PM

    I had trouble with getting the migration to work, fortunately my son knows how all this works. I had to enter db:migrate VERSION=4 then it worked. My son blames windows-any thoughts on this.

    migrate

    From: sharon, 08/25/08 06:44 PM

    I had trouble with getting the migration to work, fortunately my son knows how all this works. I had to enter db:migrate VERSION=4 then it worked. My son blames windows-any thoughts on this.

    dynamic find_by_xyz methods

    From: Bosco So, 08/13/08 03:10 PM

    Another way, perhaps cleaner, to request non-admin pages is @tabs = Page.find_all_by_admin(false) I just learned this in Ryan Bates' Railscasts #2 - http://railscasts.com/episodes/2-dynamic-find-by-methods BTW, congratulations on a great set of screencasts.

    in place editor

    From: Terje, 08/01/08 01:03 PM

    my in place editor is still not working. I have copy-pasted the macro fix but it still doesn't work. I'm using the newest version of rails and the gems. Rails 2.1.0, mongrel 1.1.5 etc... any ideas?

    Re: deployment

    From: Greg, 07/29/08 06:44 PM

    Thanks for the quick response... I am running a rails enabled server (passenger by phusion) which runs great but this is the first time I'm running rails with a database. Well, I look forward to your upcoming screencasts I know they will be very informative. In the meantime, I will check out the deployment book by pragmatic programmers. Thanks again!

    Deployment

    From: Michael Slater, 07/29/08 03:39 PM

    Greg, Deploying your app is, unfortunately, not as simple as pushing the files up to a server. You also need an application server to run the Rails code, and that server needs to be restarted whenever you change the code. We're working on a two-part deployment screencast and hope to get the first part out next week. In the meantime, if you want to learn about Rails deployment, I highly recommend the book "Deploying Rails Applications" by Pragmatic Programmers. You can purchase a PDF version from their site, and buy the printed book from any of the usual places.

    Re: Putting files on another server

    From: Greg, 07/29/08 02:53 PM

    I am trying to move my files from my dev server to a production server (deploy). I cp the entire directory to the new server, rake db:create the database, then imported my mysql.dump along with rake db:migrate. All data is in place, checked it, but my page / website does not display... anything else I need to do to deploy? Do I have to reinstall plugins via script/plugin install? Thank for your help.

    Re: pages in database

    From: Greg, 07/29/08 12:45 PM

    Hi Michael & Christopher, I having a little problem with modifying the dynamic pages. I first created a new page using the Page Admin, then in the edit mode I tried to add my erb code: --------beg snip---------------- <%= form_tag ({:action => 'uploads'}, :multipart => true)%>

    : <%= file_field 'upload', 'dataupload' %>

    <%= submit_tag "Upload" %> <%= form_tag %> --------end snip---------------- which did not work, so I used straight HTML form tags instead: --------beg snip----------------
    Select File:
    --------end snip---------------- I get a routing error, and I know I can't call my uploads_controller.rb just using "uploads" like I can with erb... I stumped on this... any hints. Thanks for making a great RoR training tutorial... the amazing part is that in this set of tutorials everything works as shown in the screencasts, I only have problems when I trying to do my own thing off what I learned =) rails has a steep learning curve but thanks for making it more fun!

    notices!

    From: ghazaleh, 07/27/08 10:05 AM

    i'm a newlearner in ruby and i have searched the internet for different learning episodes but these lessons has been such a miracle for me coz i go through the steps and everything works properly just i cant see the notice(messages) in any page! what should i do?(i'm using instantrails2.0) thanks in advance

    Sorry,

    From: Bohdan S., 06/21/08 08:12 PM

    originally code supposed to look like that:

    Migrating to AddAdminPageAttributeToPages (4)
      SQL (0.046000)   ALTER TABLE pages ADD "admin" boolean
      SQL (0.032000)   VACUUM
      Page Load (0.000000)   SELECT * FROM pages
      Page Update (0.000000)   UPDATE pages SET "created_at" = '2008-06-21 19:24:35',
        "name" = 'home',
        "title" = 'Welcome to the Learning Rails Sample App',
        "body" = '<h1>Welcome to our home page</h1>',
        "updated_at" = '2008-06-22 12:54:58',
        "admin" = 'f'
      WHERE "id" = 1

    A typo? Or a bug?

    From: Bohdan S., 06/21/08 08:09 PM

    When running ‘add_column’ migration, I’ve noticed this SQL in server’s cosole log:

    Migrating to AddAdminPageAttributeToPages (4) SQL (0.046000) ALTER TABLE pages ADD “admin” boolean SQL (0.032000) VACUUM Page Load (0.000000) SELECT * FROM pages Page Update (0.000000) UPDATE pages SET “created_at” = ‘2008-06-21 19:24:35’, “name” = ‘home’, “title” = ‘Welcome to the Learning Rails Sample App’, “body” = ‘

    Welcome to our home page

    ’, “updated_at” = ‘2008-06-22 12:54:58’, “admin” = ‘f’ WHERE “id” = 1

    Question is: doest it really suppose to set “admin”=’f’ ??... Running Rails 2.0.2 with sqlite3, on WinXP

    Code improvements

    From: Michael Slater, 06/17/08 04:12 PM

    Clemens,

    Thanks for your suggestions. I agree that adding the default value would be a good idea.

    Using update_all is also a good idea, as a matter of principle, though the resources used are so small for this application that I don’t think it makes any real difference.

    Little recommendation regarding migrations

    From: Clemens Kofler, 06/17/08 04:26 AM

    Christopher,

    great lesson as usual (I watch them even though I’m quite experienced with Rails). I have one small thing to mention: In the migration where you added the :admin column, you should probably set the column’s :default to false. This way, it updates all existing records to be non-admin pages (at least in MySQL) and future pages will automatically be non-admin unless you specifically set them to be an admin page. Moreover, I think you shouldn’t fetch all records and iterate over the collection if all you’re doing is updating one attribute without any further conditions. You could use Page.update_all for that which is especially great if you already have dozens of objects because it doesn’t fetch them from the database – thus saving a lot of resources.

    Regards, - Clemens

    RE: Migration Errors with add_column migration

    From: Christopher Haupt, 06/12/08 02:36 PM

    It is really important that the file name and the migration class name match up. The file name should be all lower case, start with a number, and each word separated by an underscore. So in our example above, the class name is AddAdminPageAttribute so the migration file name should be either 123_add_admin_page_attribute.rb (prior to Rails 2.1) or 20080605123456_add_admin_page_attribute.rb (in Rails 2.1 or higher). The numbers are an incrementing sequence number (in the former) or a timestamp (in the latter).

    Can you confirm that the file names and class names within the migration are identically named, and just differ in their formatting and initial number?

    -c

    Migration error too

    From: Darius del Rosario, 06/11/08 09:03 PM

    I am having the same problems as the previous post (Subject: Cannot migrate add_column). What could be happening here? I even used your lesson files to follow along with the tutorial so that I’d be ‘on the same page’ so to speak with you.

    Could the version of Rails be the problem, or the development machine? I’m using Windows XP SP2 and the latest Rails (v. 2.1.0). I understand you used v. 2.0.2 in the tutorials.

    Great tutorials by the way! I can’t believe you’re giving these away for free. Thanks.

    Cannot migrate add_column

    From: fil, 06/09/08 11:07 AM

    I cannot get the migration to execute properly. I keep receiving a rake error. I’ve copied the code directly from this page.

    Error is: rake aborted! uninitialized constant AddAdminPageAttributeToPages

    With trace:
    • Invoke db:migrate (first_time)
    • Invoke environment (first_time)
    • Execute environment
    • Execute db:migrate rake aborted! uninitialized constant AddAdminPageAttributeToPages /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:266:in `load_missing_constant’ /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:453:in `const_missing’ /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/dependencies.rb:465:in `const_missing’ /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/inflector.rb:257:in `constantize’ /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/string/inflections.rb:148:in `constantize’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:386:in `migration_class’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:363:in `migration_classes’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:351:in `inject’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:359:in `each’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:359:in `inject’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:359:in `migration_classes’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:339:in `migrate’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:307:in `up’ /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/migration.rb:298:in `migrate’ /usr/local/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/tasks/databases.rake:85 /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `call’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:546:in `execute’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `each’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:541:in `execute’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:508:in `invoke_with_call_chain’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `synchronize’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:501:in `invoke_with_call_chain’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:494:in `invoke’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1931:in `invoke_task’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `each’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1909:in `top_level’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1903:in `top_level’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1881:in `run’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1948:in `standard_exception_handling’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/lib/rake.rb:1878:in `run’ /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.1/bin/rake:31 /usr/local/bin/rake:19:in `load’ /usr/local/bin/rake:19

    Any advice on how to debug?

    Processing time question

    From: Michael Slater, 05/20/08 01:11 AM

    Lindsay, I understand your concern, and while I haven’t benchmarked this specifically, I’ll bet that the time to build the tabs is small and that the processing load is insignificant unless you’re running a very high-traffic site. In that case, you can easily optimize this by using the built-in Rails caching system, so the result is cached and not computed each time. Unfortunately, that is beyond the scope of this tutorial.

    responsiveness...

    From: lindsay, 05/19/08 04:47 AM

    quick question… i understand making the layout dynamic, but should we worry about the processing time? it seams that if we needed to dynamically build tabs for each page each time we browse to one it could cause some problems when trying to scale. i know this isn’t production ready and is just a demo… just curious. the lessons are great.

    thanks, lindsay

    Your lessons are excellent!

    From: Bob Walsh, 05/07/08 02:06 AM

    Just a quick comment to say your lessons are among the best I’ve seen in 25 years developing. Please! Keep up the good work!

    RE: Project Assistance

    From: Christopher Haupt, 05/05/08 10:14 AM

    John: We may eventually get to the more advanced topic of search in a future episode. For now, you might want to check out Ferret, Solr, or one of the other search engines out there. We have a few links on BuildingWebApps.com if you search for “search”. With respect towards listing out database contents of the CMS app from within a CMS generated page, we aren’t quite there yet. The steps you would need to take in the mean time are to either create a custom page (e.g. a view on the pages controller, for instance), or if you are feeling like diving in deeper, look at supporting embedded Ruby within the pages themselves.

    Project Assistance

    From: John, 05/05/08 04:00 AM

    i am creating a database however, i would like to know how to install a search engine & i have a customer tab that i want to open “listing customer” within the customer frame. however, i am having some problems with this how do i do this?

     

    Sponsored By

    New Relic Rails Performance Monitoring