cl1p.net server upgrade

At 4:00 GMT cl1p is going down for a system upgrade. It should take 1 – 2 hours.

Posted in cl1p | Leave a comment

HTML Stripper

Long story short. I needed to quickly strip all HTML from a page I was working on. I searched for an HTML Stripper but only found code examples, not a functional web application.

So to help those in need of a simple HTML tag stripper, check out my HTML tag Stripper.

If folks to link to the HTML Stripper page that would be great. It will help other folks find it when they search.

Posted in Uncategorized | 1 Comment

Rob’s Reminders r7

Major:

Added a new action to the reminders controller.

I added a new method and view to my reminders controller to show completed items.

In Reminders Controller I added

def completed
@reminders = Reminder.find(:all, :conditions => [ "done = ? and user_id = ?", true, current_user.id])
end

I also added completed.html.erb to the views for reminders. However when I accessed the /reminders/completed url I got an error message.

ActiveRecord::RecordNotFound in RemindersController#show

WTF? Why is the error in show? Well after a half hour or cursing rails I figured it out.

In the routes.rb file you will see a line

map.resources :reminders

What this does is add mappings for index, edit, create, show. With everything other then index, edit, create assigned to show.

You have to add a mapping for your new method to get around this.

map.connect 'reminders/completed', :controller => 'reminders', :action => 'completed'
map.resources :reminders

Now you can try the completed method, and it will work.

Minor changes:

Changed title, added Calendar control to created reminders.

Also robsreminders.com is finally up and running. Thanks to dream host. They are now running rails 2.0.2, and where a ton of help. I recommend them if you are looking for a rails host.

Posted in Uncategorized | Leave a comment

Robs Reminders r4

Robs Reminders r4

Implement remember me.

I had forgotten to uncomment the remember me block of code in the /app/views/account/login.rhtml file. Removing this will allow users to skip the login process once they have successfully logged in once.

Change the date/time control

The current date time control is lousy. Fortunately there is a plugin that vastly improves it.

http://code.google.com/p/calendardateselect/

script/plugin install http://calendardateselect.googlecode.com/svn/tags/calendar_date_select

Add the following to the application.html.erb layout

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”content-type” content=”text/html;charset=UTF-8″ />
<title>Reminders: <%= controller.action_name %></title>
  <%=  javascript_include_tag ‘prototype’ %>
<%= calendar_date_select_includes nil %>

Edit the /app/views/reminders/edit.html.erb file

Change

<%= f.datetime_select :due %>

to

<%= f.calendar_date_select :due, :embedded => true, :time => true %>

A restart of the app server is required after updating.

Posted in Uncategorized | Leave a comment

Robs Reminders r3 – Authentication and Base model

r3 available via http://code.google.com/p/robsreminders/ is now up and running at http://robsreminders.com .

In this check-in I installed the authentication system, created the reminder model, added a site wide layout, and created a main controller. Wow! Most updates won’t be this big. Also the contents of this entry are very similar to my previous tutorial on act_as_authenticated.

The first step of course is to build the database and create authentication.

rake db:create

(Note: I had to change the socket: in config/database.yml on my ubuntu machine, I did this by generating a separate app and coping the config information.)

script/plugin install http://svn.techno-weenie.net/projects/plugins/acts_as_authenticated

ruby script/generate authenticated user account

rake db:migrate

Add the AuthenticatedSystem to /app/controllers/application.rb

class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time

include AuthenticatedSystem

The primary model for this application is the Reminder. Now I don’t have a complete design for the application, but this is what I have so far.

Reminder has title, body, due, complete.

script/generate scaffold Reminder title:string body:text done:boolean due:datetime

and of course tied to a user_id

script/generate migration add_user_id_to_reminder

class AddUserIdToReminder < ActiveRecord::Migration
def self.up

add_column :reminders, :user_id, :integer
end

def self.down
remove_column :reminders, :user_id
end
end

add the one to many relation between reminder and user

user.rb
has_may :reminders

reminder.rb
belongs_to :user

Create a main controller, this will serve as the root of the application. With and index method, and an index view.

Map the main controller to the root. routes.rb

map.root :controller => “main”

define an application wide template containing a login tool-bar.

/app/views/layouts/application.html.erb

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>

<html xmlns=”http://www.w3.org/1999/xhtml” xml:lang=”en” lang=”en”>
<head>
<meta http-equiv=”content-type” content=”text/html;charset=UTF-8″ />
<title>Reminders: <%= controller.action_name %></title>
<%= stylesheet_link_tag ‘scaffold’ %>

</head>
<body>
<div style=”border-bottom:solid 1px black;”>

Robs Reminders
<span style=”float:right;”>
<% if current_user == :false %>
<%= link_to “Login”, {:controller => ‘account’, :action => ‘login’}%>
<%= link_to “Signup”, {:controller => ‘account’, :action => ‘signup’}%>
<% else %>
<%= current_user.login %>
<%= link_to “Logout”, {:controller => ‘account’, :action => ‘logout’}%>
<%= link_to “Edit URL”, {:controller => ‘main’, :action => ‘edit’}%>
<%= link_to “Reminders”, {:controller => ‘reminders’, :action => ‘index’}%>
<% end%>
</span>
</div>
<p style=”color: green”><%= flash[:notice] %></p>
<%= yield %>

</body>
</html>

delete the index.html page

Delete all other layout files

Modify the account controller to redirect to the main page.

Modify the reminders controller to user the current_user for loading and saving reminders. (as seen in the authentication tutorial. )
This takes us to SVN r3.

Posted in Uncategorized | Leave a comment