Index: app/helpers/application_helper.rb =================================================================== --- app/helpers/application_helper.rb (revision 36) +++ app/helpers/application_helper.rb (working copy) @@ -42,7 +42,7 @@ end def link_to_tag(tag) - references = tag.news_items_count + references = tag.news_items.count styles = [] styles << 'font-weight:' + ((references > 1) ? 'bold' : 'normal') styles << 'font-size:9pt' if references <= 2 Index: app/models/user.rb =================================================================== --- app/models/user.rb (revision 36) +++ app/models/user.rb (working copy) @@ -20,7 +20,7 @@ # @user = User.authenticate('bob', 'bobpass') # def self.authenticate(login, pass) - find_first(["login = ? AND password = ?", login, sha1(pass)]) + User.find(:first, :conditions => ["login = ? AND password = ?", login, sha1(pass)]) end def name @@ -28,7 +28,7 @@ end def self.administrator - find :first, :conditions => ["admin = ?", true] + User.find(:first, :conditions => ["admin = ?", true]) end def visit_now(stamp = DateTime.now) Index: app/models/photo.rb =================================================================== --- app/models/photo.rb (revision 36) +++ app/models/photo.rb (working copy) @@ -11,6 +11,6 @@ def self.family_photo return nil if Setting[:family_photo_id].nil? - find Setting[:family_photo_id] + Photo.find Setting[:family_photo_id] end -end \ No newline at end of file +end Index: app/controllers/account_controller.rb =================================================================== --- app/controllers/account_controller.rb (revision 36) +++ app/controllers/account_controller.rb (working copy) @@ -5,16 +5,16 @@ @@confirmation = '1bc7ac90bdd8e9f0121dcf99d83528b5' def login - case @request.method + case request.method when :post - if @session[:user] = User.authenticate(@params[:user_login], @params[:user_password]) - + logger.warn(" --> 1 session: #{session[:user]}") + if session[:user] = User.authenticate(params[:user_login], params[:user_password]) + logger.warn(" --> 2 session: #{session[:user]}") flash[:notice] = "Sign-in successful" redirect_back_or_default :action => "welcome" else - flash.now[:error] = "Sign-in unsuccessful" - - @login = @params[:user_login] + flash.now[:error] = "Sign-in unsuccessful" + @login = params[:user_login] end end end @@ -25,18 +25,18 @@ @menu_left = 'menu_left_admin_signup' end - @user = User.new(@params[:user]) + @user = User.new(params[:user]) @security = OpenStruct.new(params[:security]) - if @request.post? + if request.post? if @admin_signup @user.admin = true if @user.save - @session[:user] = User.authenticate(@user.login, @params[:user][:password]) + session[:user] = User.authenticate(@user.login, params[:user][:password]) redirect_to :controller => 'welcome', :action => 'first_time_done' end elsif params[:security][:password] == Setting[:family_password] if @user.save - @session[:user] = User.authenticate(@user.login, @params[:user][:password]) + session[:user] = User.authenticate(@user.login, params[:user][:password]) flash[:notice] = "Signup successful" redirect_back_or_default :action => "welcome" end @@ -47,7 +47,7 @@ end def logout - @session[:user] = nil + session[:user] = nil end def welcome @@ -109,7 +109,7 @@ def forgot_password @security = OpenStruct.new(params[:security]) if request.post? - @user = User.find_by_email @security.email + @user = User.find_by_email(@security.email) if @user url = url_for({ :controller => 'account', Index: app/controllers/administrator_controller.rb =================================================================== --- app/controllers/administrator_controller.rb (revision 36) +++ app/controllers/administrator_controller.rb (working copy) @@ -44,12 +44,12 @@ def signup @menu_left = 'administrator/menu_left_signup' if @first_time_install @admin_signup = true - @user = User.new(@params[:user]) + @user = User.new(params[:user]) @security = OpenStruct.new(params[:security]) - if @request.post? + if request.post? @user.admin = true if @user.save - @session[:user] = User.authenticate(@user.login, @params[:user][:password]) + session[:user] = User.authenticate(@user.login, params[:user][:password]) redirect_to :action => 'setup_done' end end Index: app/views/address_book/index.rhtml =================================================================== --- app/views/address_book/index.rhtml (revision 36) +++ app/views/address_book/index.rhtml (working copy) @@ -11,10 +11,10 @@ You can click on your name or photo to change your contact information.
<% end -%> - <% unless user.news_items_count == 0 -%> + <% unless user.news_items.count == 0 -%> <%= render :partial => 'account/user_news_links', :locals => {:user => user} %> <% end -%> -<% end %> \ No newline at end of file +<% end %> Index: app/views/administrator/upload_family_photo.rhtml =================================================================== --- app/views/administrator/upload_family_photo.rhtml (revision 36) +++ app/views/administrator/upload_family_photo.rhtml (working copy) @@ -1,7 +1,7 @@

Upload a Family Photo

This family photo will be displayed on the front page of your Family Connection site. It should be at least 512 pixels wide—anything larger is fine, since the picture will be resized automatically. If you don't know if your picture is large enough, don't worry. Just try it out and see if it looks right! -<%= start_form_tag({}, :multipart => true)%> +<% form_tag({}, :multipart => true) do %>

@@ -21,4 +21,4 @@
<%= submit_tag "Send Photo »" %>
-<%= end_form_tag %> \ No newline at end of file +<% end %> Index: app/views/administrator/setup.rhtml =================================================================== --- app/views/administrator/setup.rhtml (revision 36) +++ app/views/administrator/setup.rhtml (working copy) @@ -7,7 +7,7 @@

Upload a Family Photo

This family photo will be displayed on the front page of your Family Connection site. It should be at least 512 pixels wide—anything larger is fine, since the picture will be resized automatically. If you don't know if your picture is large enough, don't worry. Just try it out and see if it looks right! -<%= start_form_tag({}, :multipart => true)%> +<% form_tag({}, :multipart => true) do %>

@@ -73,7 +73,7 @@
<%= submit_tag "Save Settings" %>
<% end %> -<%= end_form_tag %> +<% end %>

© 2005-2006 <%= link_to "Duane Johnson", "http://blog.inquirylabs.com/" %> & Roxsane Fox. Design by Andreas Viklund.

Index: app/views/administrator/signup.rhtml =================================================================== --- app/views/administrator/signup.rhtml (revision 36) +++ app/views/administrator/signup.rhtml (working copy) @@ -1,5 +1,5 @@

Register

-<%= start_form_tag({:action => "signup"}, :multipart => true) %> +<% form_tag({:action => "signup"}, :multipart => true) do %>

Family Administrator Registration

@@ -11,5 +11,5 @@

That's it! Click the Register button to finish.

-<%= end_form_tag %> +<% end %> Index: app/views/layouts/application.rhtml =================================================================== --- app/views/layouts/application.rhtml (revision 36) +++ app/views/layouts/application.rhtml (working copy) @@ -22,13 +22,13 @@
- <% if flash[:notice] or flash[:error] %> -
- <% if flash[:notice] -%>

<%= flash[:notice] %>

<% end %> - <% if flash[:error] -%>

<%= flash[:error] %>

<% end %> -
- <% end -%> + <% if flash[:notice] or flash[:error] %> +
+ <% if flash[:notice] -%>

<%= flash[:notice] %>

<% end %> + <% if flash[:error] -%>

<%= flash[:error] %>

<% end %> +
+ <% end -%> <%= @content_for_layout %>
- \ No newline at end of file + Index: app/views/account/upload_photo.rhtml =================================================================== --- app/views/account/upload_photo.rhtml (revision 36) +++ app/views/account/upload_photo.rhtml (working copy) @@ -1,4 +1,4 @@ -<%= start_form_tag({:action => "update", :id => @user}, :multipart => true) %> +<% form_tag({:action => "update", :id => @user}, :multipart => true) do %>
<%= error_messages_for 'user' %>
@@ -24,5 +24,5 @@
-<%= end_form_tag %> +<% end %> Index: app/views/account/forgot_password.rhtml =================================================================== --- app/views/account/forgot_password.rhtml (revision 36) +++ app/views/account/forgot_password.rhtml (working copy) @@ -1,10 +1,10 @@

Password Reminder

Type in your e-mail address

-<%= start_form_tag %> +<% form_tag do %>

If you've forgotten your sign-in name or password, we can email it to you directly.


<%= text_field 'security', 'email' %> <%= submit_tag 'Send Me an Email' %> -<%= end_form_tag %> \ No newline at end of file +<% end %> Index: app/views/account/edit.rhtml =================================================================== --- app/views/account/edit.rhtml (revision 36) +++ app/views/account/edit.rhtml (working copy) @@ -1,4 +1,4 @@ -<%= start_form_tag({:action => "update", :id => @user}, :multipart => true) %> +<% form_tag({:action => "update", :id => @user}, :multipart => true) do %>

Edit User Info

@@ -7,5 +7,5 @@ <%= render :partial => 'form' %>
-<%= end_form_tag %> +<% end %> Index: app/views/account/signup.rhtml =================================================================== --- app/views/account/signup.rhtml (revision 36) +++ app/views/account/signup.rhtml (working copy) @@ -1,5 +1,5 @@

Register

-<%= start_form_tag({:action => "signup"}, :multipart => true) %> +<% form_tag({:action => "signup"}, :multipart => true) do %>

Family Member Registration

@@ -18,5 +18,5 @@

That's it! Click the Register button to finish.

-<%= end_form_tag %> +<% end %> Index: app/views/account/login.rhtml =================================================================== --- app/views/account/login.rhtml (revision 36) +++ app/views/account/login.rhtml (working copy) @@ -1,11 +1,11 @@ -<%= start_form_tag :action=> "login" %> +<% form_tag :action=> "login" do %>

Please sign in

If you're visiting this page, then we are assuming that you've already <%= link_to "registered yourself", :action => 'signup' %>. If not, then please <%= link_to 'click here', :action => 'signup' %> to register before signing in.

- <% if @flash['notice'] %> -
<%= @flash['notice'] %>
+ <% if flash['notice'] %> +
<%= flash['notice'] %>
<% end %>
@@ -22,5 +22,5 @@
-<%= end_form_tag %> +<% end %> Index: app/views/account/_user_news_links.rhtml =================================================================== --- app/views/account/_user_news_links.rhtml (revision 36) +++ app/views/account/_user_news_links.rhtml (working copy) @@ -1,9 +1,9 @@ -<% if user.news_items_count == 0 -%> +<% if user.news_items.count == 0 -%> <%= current_user.id == user.id ? 'You have' : user.firstname + ' has' %> not posted any news items. <% else -%> <%= current_user.id == user.id ? 'You have' : user.firstname + ' has' %> - posted <%= pluralize(user.news_items_count, 'news item') %>. + posted <%= pluralize(user.news_items.count, 'news item') %>. <%= link_to 'Click here', :controller => 'news', :action => 'from', :id => user %> to - read <%= user.news_items_count == 1 ? 'it' : 'them' %>. + read <%= user.news_items.count == 1 ? 'it' : 'them' %>. <% end -%> Index: app/views/news/edit.rhtml =================================================================== --- app/views/news/edit.rhtml (revision 36) +++ app/views/news/edit.rhtml (working copy) @@ -1,7 +1,7 @@

Edit News Item

-<%= start_form_tag({:action => 'update', :id => @news_item}, :multipart => true) %> +<% form_tag({:action => 'update', :id => @news_item}, :multipart => true) do %> <%= render :partial => 'form' %> <%= submit_tag 'Update this post' %> -<%= end_form_tag %> +<% end %> Index: app/views/news/index.rhtml =================================================================== --- app/views/news/index.rhtml (revision 36) +++ app/views/news/index.rhtml (working copy) @@ -10,7 +10,7 @@
- <%= start_form_tag :action => 'search', :id => (@author ? @author.id : nil) %> + <% form_tag :action => 'search', :id => (@author ? @author.id : nil) do %> Search by author: <%= collection_select 'search', 'user_id', User.find(:all, :order => 'lastname, firstname'), @@ -19,7 +19,7 @@ <%= text_field 'search', 'tags', :size => 10 %> <%= submit_tag 'Go' %> <%= link_to_function "show tags", "toggle_tags()" %> - <%= end_form_tag %> + <% end %>

Index: app/views/news/_news_item.rhtml =================================================================== --- app/views/news/_news_item.rhtml (revision 36) +++ app/views/news/_news_item.rhtml (working copy) @@ -6,7 +6,7 @@

<%= news_item.title %><% if news_item.recent? -%> <%= image_tag 'new.gif', :align => 'absmiddle', :style => 'float: none; border: 0px' %><% end -%>

- <% if news_item.photos_count > 0 -%> + <% if news_item.photos.count > 0 -%> <% for photo in news_item.photos -%> <% thumb_url = url_for_image_column(photo, "image", @@ -51,4 +51,4 @@
- \ No newline at end of file + Index: app/views/news/new.rhtml =================================================================== --- app/views/news/new.rhtml (revision 36) +++ app/views/news/new.rhtml (working copy) @@ -1,7 +1,7 @@

Post News

-<%= start_form_tag({:action => 'create'}, :multipart => true) %> +<% form_tag({:action => 'create'}, :multipart => true) do %> <%= render :partial => 'form' %> <%= submit_tag "Post it up!" %> -<%= end_form_tag %> +<% end %> Index: db/migrate/004_add_birthday_and_visited_at_columns.rb =================================================================== --- db/migrate/004_add_birthday_and_visited_at_columns.rb (revision 36) +++ db/migrate/004_add_birthday_and_visited_at_columns.rb (working copy) @@ -1,11 +0,0 @@ -class AddBirthdayAndVisitedAtColumns < ActiveRecord::Migration - def self.up - add_column :users, :birthday, :datetime - add_column :users, :visited_at, :datetime - end - - def self.down - remove_column :users, :visited_at - remove_column :users, :birthday - end -end Index: db/migrate/005_tags_photos.rb =================================================================== --- db/migrate/005_tags_photos.rb (revision 0) +++ db/migrate/005_tags_photos.rb (revision 0) @@ -0,0 +1,13 @@ +class TagsPhotos < ActiveRecord::Migration + def self.up + create_table :tags_photos, :id => false do |t| + t.integer :tag_id + t.integer :photo_id + t.timestamps + end + end + + def self.down + drop_table :tags_photos + end +end Index: db/migrate/006_tags_news_items.rb =================================================================== --- db/migrate/006_tags_news_items.rb (revision 0) +++ db/migrate/006_tags_news_items.rb (revision 0) @@ -0,0 +1,13 @@ +class TagsNewsItems < ActiveRecord::Migration + def self.up + create_table :tags_news_items, :id => false do |t| + t.integer :tag_id + t.integer :news_item_id + t.timestamps + end + end + + def self.down + drop_table :tags_news_items + end +end Index: db/migrate/002_create_news_items.rb =================================================================== --- db/migrate/002_create_news_items.rb (revision 0) +++ db/migrate/002_create_news_items.rb (revision 0) @@ -0,0 +1,18 @@ +class CreateNewsItems < ActiveRecord::Migration + def self.up + create_table :news_items do |t| + t.string :title + t.text :body + t.text :body_filtered + t.text :extended + t.text :extended_filtered + t.integer :created_by_id + t.integer :updated_by_id + t.timestamps + end + end + + def self.down + drop_table :news_items + end +end Index: db/migrate/003_create_photos.rb =================================================================== --- db/migrate/003_create_photos.rb (revision 0) +++ db/migrate/003_create_photos.rb (revision 0) @@ -0,0 +1,16 @@ +class CreatePhotos < ActiveRecord::Migration + def self.up + create_table :photos do |t| + t.integer :news_item_id + t.string :image + t.string :description + t.integer :created_by_id + t.integer :updated_by_id + t.timestamps + end + end + + def self.down + drop_table :photos + end +end Index: db/migrate/001_create_users.rb =================================================================== --- db/migrate/001_create_users.rb (revision 0) +++ db/migrate/001_create_users.rb (revision 0) @@ -0,0 +1,26 @@ +class CreateUsers < ActiveRecord::Migration + def self.up + create_table :users do |t| + t.string :login + t.string :password + t.string :firstname + t.string :lastname + t.string :phone + t.string :email + t.string :street + t.string :city + t.string :province + t.string :postal + t.string :country + t.string :portrait + t.boolean :admin + t.date :birthday + t.datetime :visited_at + t.timestamps + end + end + + def self.down + drop_table :users + end +end Index: db/migrate/004_create_tags.rb =================================================================== --- db/migrate/004_create_tags.rb (revision 0) +++ db/migrate/004_create_tags.rb (revision 0) @@ -0,0 +1,12 @@ +class CreateTags < ActiveRecord::Migration + def self.up + create_table :tags do |t| + t.string :name + t.timestamps + end + end + + def self.down + drop_table :tags + end +end Index: db/migrate/007_settings.rb =================================================================== --- db/migrate/007_settings.rb (revision 0) +++ db/migrate/007_settings.rb (revision 0) @@ -0,0 +1,13 @@ +class Settings < ActiveRecord::Migration + def self.up + create_table :settings do |t| + t.string :name + t.text :value + t.timestamps + end + end + + def self.down + drop_table :settings + end +end Index: db/migrate/001_add_portrait_column.rb =================================================================== --- db/migrate/001_add_portrait_column.rb (revision 36) +++ db/migrate/001_add_portrait_column.rb (working copy) @@ -1,9 +0,0 @@ -class AddPortraitColumn < ActiveRecord::Migration - def self.up - add_column :users, :portrait, :string - end - - def self.down - remove_column :users, :portrait - end -end Index: db/migrate/002_add_photos_table.rb =================================================================== --- db/migrate/002_add_photos_table.rb (revision 36) +++ db/migrate/002_add_photos_table.rb (working copy) @@ -1,38 +0,0 @@ -class AddPhotosTable < ActiveRecord::Migration - def self.up - create_table :photos do |t| - t.column :news_item_id, :integer - t.column :image, :string - t.column :description, :string - t.column :created_at, :datetime - t.column :updated_at, :datetime - t.column :created_by_id, :integer - t.column :updated_by_id, :integer - end - - create_table :tags do |t| - t.column :name, :string - end - - create_table :tags_news_items, :id => false do |t| - t.column :tag_id, :integer - t.column :news_item_id, :integer - end - - create_table :tags_photos, :id => false do |t| - t.column :tag_id, :integer - t.column :photo_id, :integer - end - - add_column :news_items, :updated_at, :datetime - end - - def self.down - remove_column :news_items, :updated_at - - drop_table :tags_photos - drop_table :tags_news_items - drop_table :tags - drop_table :photos - end -end Index: db/migrate/003_admin_flag_and_settings_table.rb =================================================================== --- db/migrate/003_admin_flag_and_settings_table.rb (revision 36) +++ db/migrate/003_admin_flag_and_settings_table.rb (working copy) @@ -1,14 +0,0 @@ -class AdminFlagAndSettingsTable < ActiveRecord::Migration - def self.up - add_column :users, :admin, :boolean - create_table :settings do |t| - t.column :name, :string - t.column :value, :text - end - end - - def self.down - drop_table :settings - remove_column :users, :admin - end -end