JavaScript · Rails 3 · Ruby On Rails

Comparition of Adopting Unobstructive Javascript and XSS in Rails 2 & 3

Cross-Site-Scripting in Rails 2 <%= @post.body %> –> Unsafe <%= h @post.body %> –> Safe Cross-Site-Scripting in Rails 3 <%= @post.body %> –> Safe <%= raw @post.body %> –> Unsafe Adopting Unobstructive Javascript Example 1 : Rails 2: <%= link_to_remote ‘Show’, :url => post %> Will generate a HTML like, “<a href=”#” onclick=”new Ajax.Request(‘/posts/1′, {asynchronous:true,… Continue reading Comparition of Adopting Unobstructive Javascript and XSS in Rails 2 & 3

Rails 3

Difference in ActionMailer between rails 2 and rails 3

Rails 2 def welcome(user)     @recipients = “#{user.email}”     @from = “admin@samplesite.com”     @subject = “Welcome Mail”     @body[:user] = user end Rails 3 def welcome(user)     @user = user     mail(:from=>”admin@samplesite.com”, :to=>”#{user.email}”, :subject=>”Welcome Mail”) end We can also set the default value if it is common for all… Continue reading Difference in ActionMailer between rails 2 and rails 3

Rails 3 · ruby

Routing in Rails 3

Root Route root :to => ‘welcome#show’. Named Route match ‘logout’, :to => ‘sessions#destroy’ RESTful Routes resources :products Nested Resources resources :projects do resources :tasks, :people end Namespaced Resources namespace :admin do resources :projects end Some example : match “/about(.:format)” => “info#about”, :as => :about match “/:year(/:month(/:day))” => “info#about”, :constraints => { :year => /\d{4}/, :month… Continue reading Routing in Rails 3