public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
Description preview
Michael Hartl (author)
Wed May 07 12:08:42 -0700 2008
commit  ca931746525b469a2384bb1414adc6a0186ab9bc
tree    48ce3bb0901c35a74945920ef4a86dc4f495e39c
parent  ed4fb244bd0c174df2814784e443cffa1a12d9b1
...
88
89
90
91
 
92
93
94
 
95
96
97
...
122
123
124
 
 
 
 
125
126
...
88
89
90
 
91
92
93
94
95
96
97
98
...
123
124
125
126
127
128
129
130
131
0
@@ -88,10 +88,11 @@
0
     respond_to do |format|
0
       case params[:type]
0
       when 'info_edit'
0
- if @person.update_attributes(params[:person])
0
+ if @person.update_attributes(params[:person]) and !preview?
0
           flash[:success] = 'Profile updated!'
0
           format.html { redirect_to(@person) }
0
         else
0
+ @preview = @person.description
0
           format.html { render :action => "edit" }
0
         end
0
       when 'password_edit'
0
@@ -122,6 +123,10 @@
0
   
0
     def correct_user_required
0
       redirect_to home_url unless Person.find(params[:id]) == current_person
0
+ end
0
+
0
+ def preview?
0
+ params["commit"] == "Preview"
0
     end
0
 end
...
6
7
8
9
 
10
11
12
...
17
18
19
 
 
 
 
 
20
21
22
...
28
29
30
31
 
 
32
33
34
...
6
7
8
 
9
10
11
12
...
17
18
19
20
21
22
23
24
25
26
27
...
33
34
35
 
36
37
38
39
40
0
@@ -6,7 +6,7 @@
0
   <h3>Personal details</h3>
0
 
0
     <%= error_messages_for :person %>
0
-
0
+
0
     <% form_for @person do |f| %>
0
 
0
       <div class="form_row">
0
@@ -17,6 +17,11 @@
0
       <div class="form_row">
0
         <label for="person_description">Description
0
         </label>
0
+
0
+ <%- unless @preview.nil? -%>
0
+ <%= display @preview %>
0
+ <%- end -%>
0
+
0
         <p><%= formatting_note %></p>
0
         <%= f.text_area :description %>
0
       </div>
0
@@ -28,7 +33,8 @@
0
   
0
       <div class="form_row">
0
         <%= f.submit "Update", :class => "button" %>
0
- </div>
0
+ <%= f.submit "Preview", :id => "preview", :class => "button" %>
0
+ </div>
0
       <input type="hidden" name="type" value="info_edit" />
0
   <% end %>
0
 

Comments

    No one has commented yet.