Linking to the Current Action
1 2 <%= link_to "Insert Link Text", :action => controller.action_name %>
14093 users tagging and storing useful source code snippets
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
1 2 <%= link_to "Insert Link Text", :action => controller.action_name %>
1 2 Options +FollowSymLinks +ExecCGI 3 4 RewriteEngine On 5 6 RewriteCond %{SCRIPT_FILENAME} -d 7 RewriteCond %{SCRIPT_FILENAME} ^.*[^\/]$ 8 RewriteRule ^(.*)$ $1/ [N] 9 10 #Put the directory your Rails app is in here. 11 RewriteBase /directory 12 13 RewriteRule ^$ index.html [QSA] 14 RewriteRule ^([^.]+)$ $1.html [QSA] 15 16 RewriteCond %{REQUEST_FILENAME} !-f 17 RewriteRule ^(.*)$ dispatch.cgi?$1 [QSA,L]
1 2 <table> 3 <% @instance.in_groups_of(5) do |row| %> 4 <tr> 5 <% row.each do |data| %> 6 # The nil check is required because Rails pads empty table cells with nil. 7 <td><%= data.field unless data.nil? %></td> 8 <% end %> 9 </tr> 10 <% end %> 11 </table>
1 2 def updatesettings 3 # This method is probably one of the most messiest things I have ever written. 4 # It's a piece of garbage and an example of how NOT to code something like this. 5 @settings = User.find(params[:id]) 6 @settings.attributes = params[:settings] 7 if request.post? 8 oldpassword = @settings.password 9 @settings.login = params[:settings][:login] 10 @settings.email = params[:settings][:email] 11 if params[:password][:newpassword1] != "" || params[:password][:newpassword2] != "" 12 if params[:password][:newpassword1] == params[:password][:newpassword2] 13 @settings.password = Digest::SHA1.hexdigest("FAKE CODE HERE--#{params[:password][:newpassword1]}--") 14 else 15 flash[:sucess] = "Your new passwords don't match." 16 redirect = "settings" 17 end 18 end 19 @settings.save 20 if params[:id] != nil 21 if redirect == nil && "#{params[:id]}" != "#{session[:user_id]}" 22 flash[:sucess] = "User has been sucessfully updated." 23 redirect_to :controller => "users" 24 else 25 redirect_to :action => "index", :id => params[:id] 26 end 27 else 28 flash[:sucess] = "Your settings have been updated." 29 redirect_to :action => "users" 30 end 31 end 32 end
1 2 settings = @settings.updatesettings(params[:id], params[:settings][:login], params[:settings][:email], params[:password][:newpassword1], params[:password][:newpassword2])