Permalink
Browse files

new topics controller

  • Loading branch information...
Matt Hodgson
Matt Hodgson committed May 21, 2009
1 parent 67b9bf1 commit f4c332f8a0562b0f835242aa22fee38e72752f81
@@ -0,0 +1,30 @@
+class TopicsController < ApplicationController
+ before_filter :require_user
+
+ def new
+ @topic = Topic.new
+ end
+
+ def create
+ @topic = Topic.new(params[:topic])
+ end
+
+ def show
+ @topic = Topic.find(params[:id])
+ end
+
+ def edit
+ @topic = Topic.find(params[:id])
+ end
+
+ def update
+ @topic = Topic.find(params[:id])
+ if @topic.update_attributes(params[:topic])
+ flash[:notice] = "Topic updated!"
+ redirect_to topics_url
+ else
+ render :action => :edit
+ end
+ end
+
+end
@@ -8,7 +8,7 @@ def new
def create
@user_session = UserSession.new(params[:user_session])
-
+
@user_session.save do |result|
if result
flash[:notice] = "Login successful!"
@@ -10,4 +10,13 @@ def body_class
def body_id
"#{@controller.controller_name.dasherize}-#{@controller.action_name.dasherize}"
end
+
+ def param_display(parameter)
+ display = case parameter.type
+ when 'String' : parameter.value
+ when 'Date' : Date.parse(parameter.value).to_formatted_s(:main_date)
+ else 'NOT DONE YET'
+ end
+ end
+
end
@@ -1,12 +0,0 @@
-<h1>Change My Password</h1>
-
-<% form_for @user, :url => password_reset_path, :method => :put do |f| %>
- <%= f.error_messages %>
- <%= f.label :password %><br />
- <%= f.password_field :password %><br />
- <br />
- <%= f.label :password_confirmation %><br />
- <%= f.password_field :password_confirmation %><br />
- <br />
- <%= f.submit "Update my password and log me in" %>
-<% end %>
@@ -0,0 +1,15 @@
+%h1 Change My Password
+
+-form_for @user, :url => password_reset_path, :method => :put do |f|
+ = f.error_messages
+ = f.label :password
+ %br
+ = f.password_field :password
+ %br
+ %br
+ = f.label :password_confirmation
+ %br
+ = f.password_field :password_confirmation
+ %br
+ %br
+ = f.submit "Update my password and log me in"
@@ -1,11 +0,0 @@
-<h1>Forgot Password</h1>
-
-Fill out the form below and instructions to reset your password will be emailed to you:<br />
-<br />
-
-<% form_tag password_resets_path do %>
- <label>Email:</label><br />
- <%= text_field_tag "email" %><br />
- <br />
- <%= submit_tag "Reset my password" %>
-<% end %>
@@ -0,0 +1,13 @@
+%h1 Forgot Password
+
+Fill out the form below and instructions to reset your password will be emailed to you:
+%br
+%br
+
+-form_tag password_resets_path do
+ %label Email:
+ %br
+ = text_field_tag "email"
+ %br
+ %br
+ = submit_tag "Reset my password"
@@ -1,14 +0,0 @@
-<h1>Login</h1>
-
-<% form_for @user_session, :url => user_session_path do |f| %>
- <%= f.error_messages %>
- <%= f.label :login %><br />
- <%= f.text_field :login %><br />
- <br />
- <%= f.label :password %><br />
- <%= f.password_field :password %><br />
- <br />
- <%= f.check_box :remember_me %><%= f.label :remember_me %><br />
- <br />
- <%= f.submit "Login" %>
-<% end %>
@@ -0,0 +1,19 @@
+%h1 Login
+
+-form_for @user_session, :url => user_session_path do |f|
+ = f.error_messages
+ = f.label :login
+ %br
+ = f.text_field :login
+ %br
+ %br
+ = f.label :password
+ %br
+ = f.password_field :password
+ %br
+ %br
+ = f.check_box :remember_me
+ = f.label :remember_me
+ %br
+ %br
+ = f.submit "Login"
@@ -1,8 +0,0 @@
-<%= form.label :login %><br />
-<%= form.text_field :login %><br />
-<br />
-<%= form.label :password, form.object.new_record? ? nil : "Change password" %><br />
-<%= form.password_field :password %><br />
-<br />
-<%= form.label :password_confirmation %><br />
-<%= form.password_field :password_confirmation %><br />
@@ -0,0 +1,14 @@
+= form.label :login
+%br
+= form.text_field :login
+%br
+%br
+= form.label :password, form.object.new_record? ? nil : "Change password"
+%br
+= form.password_field :password
+%br
+%br
+= form.label :password_confirmation
+%br
+= form.password_field :password_confirmation
+%br
@@ -1,9 +0,0 @@
-<h1>Edit My Account</h1>
-
-<% form_for @user, :url => account_path do |f| %>
- <%= f.error_messages %>
- <%= render :partial => "form", :object => f %>
- <%= f.submit "Update" %>
-<% end %>
-
-<br /><%= link_to "My Profile", account_path %>
@@ -0,0 +1,9 @@
+%h1 Edit My Account
+
+-form_for @user, :url => account_path do |f|
+ = f.error_messages
+ = render :partial => "form", :object => f
+ = f.submit "Update"
+
+%br
+= link_to "My Profile", account_path
@@ -1,7 +0,0 @@
-<h1>Register</h1>
-
-<% form_for @user, :url => account_path do |f| %>
- <%= f.error_messages %>
- <%= render :partial => "form", :object => f %>
- <%= f.submit "Register" %>
-<% end %>
@@ -0,0 +1,6 @@
+%h1 Register
+
+-form_for @user, :url => account_path do |f|
+ = f.error_messages
+ = render :partial => "form", :object => f
+ = f.submit "Register"
View
@@ -36,7 +36,11 @@
map.root :controller => "user_sessions", :action => "new"
map.resource :account, :controller => 'users'
-
+
+ map.resources :topic
+
+ map.tags 'topic/:id/topics', :controller => 'topics', :action => 'topics'
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
# map.root :controller => "welcome"
@@ -15,4 +15,4 @@
config.to_prepare do
OpenID::Util.logger = Rails.logger
ActionController::Base.send :include, OpenIdAuthentication
-end
+end

0 comments on commit f4c332f

Please sign in to comment.