This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ app/views/posts/_form.html.haml | |
= form_for @post, :url => collection_url do |f| | |
%fieldset | |
%legend New Post | |
%ol | |
%li= f.text_field :title | |
%li= f.text_field :tag_list | |
%fieldset | |
%ol | |
%li= f.text_area :body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> @post = Post.find(BSON::ObjectId("47cc67093475061e3d95369d")) | |
=> #<Post _id: 47cc67093475061e3d95369d, slug: "life-the-universe-and-everything"> | |
>> post_path(@post) | |
=> /posts/47cc67093475061e3d95369d | |
>> post_path(@post, :slug => @post.slug) | |
=> /posts/47cc67093475061e3d95369d/life-the-universe-and-everything |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ rake routes | |
posts GET /posts(.:format) {:action=>"index", :controller=>"posts"} | |
posts POST /posts(.:format) {:action=>"create", :controller=>"posts"} | |
new_post GET /posts/new(.:format) {:action=>"new", :controller=>"posts"} | |
edit_post GET /posts/:id(/:slug)/edit(.:format) {:action=>"edit", :controller=>"posts"} | |
post GET /posts/:id(/:slug)(.:format) {:action=>"show", :controller=>"posts"} | |
post PUT /posts/:id(/:slug)(.:format) {:action=>"update", :controller=>"posts"} | |
post DELETE /posts/:id(/:slug)(.:format) {:action=>"destroy", :controller=>"posts"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/routes.rb | |
Example::Application.routes.draw do | |
resources :posts, :slug => true | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/routes_with_slugs.rb | |
require 'action_dispatch' | |
module ActionDispatch | |
module Routing | |
class Mapper | |
module Resources | |
RESOURCE_OPTIONS << :slug | |
class Resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ app/views/layouts/application.html.haml | |
%html{ :data => { :web_property_id => ENV['GOOGLE_WEB_PROPERTY_ID'] } } | |
%head | |
%title My Great Site | |
= stylesheet_link_tag 'screen.css', :media => 'screen, projection' | |
= javascript_include_tag :defaults | |
%body | |
#content= yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// public/javascripts/application.js | |
var _gaq = _gaq || []; | |
$(document).ready(function() { | |
var web_property_id = $('html').attr('data-web_property_id'); | |
if ((typeof web_property_id) != 'undefined') { | |
_gaq.push(['_setAccount', web_property_id]); | |
_gaq.push(['_trackPageview']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ app/views/layouts/application.html.haml | |
%html{ :data => { :web_property_id => 'UA-XXXXXXX-1' } } | |
%head | |
%title My Great Site | |
= stylesheet_link_tag 'screen.css', :media => 'screen, projection' | |
= javascript_include_tag :defaults | |
%body | |
#content= yield |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// public/javascripts/application.js | |
var _gaq = _gaq || []; | |
$(document).ready(function() { | |
_gaq.push(['_setAccount', 'UA-XXXXXXX-1']); | |
_gaq.push(['_trackPageview']); | |
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/ app/views/layouts/application.html.haml | |
%html | |
%head | |
%title My Great Site | |
= stylesheet_link_tag 'screen.css', :media => 'screen, projection' | |
= javascript_include_tag :defaults | |
%body | |
#content= yield | |
:javascript | |
var _gaq = _gaq || []; |
NewerOlder