Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #posts_controller.rb
- class PostsController < ApplicationController
- def index
- @post = Post.limit(5)
- end
- end
- #_post.html.erb located app/views/posts
- <div class="col-sm-3 single-post-card" id=<%= post_path(post.id) %>>
- <div class="card">
- <div class="card-block">
- <h4 class="post-text">
- <%= truncate(post.title, :length => 60) %>
- </h4>
- <div class="post-content">
- <div class="posted-by">Posted by <%= post.user.name %></div>
- <h3><%= post.title %></h3>
- <p><%= post.content %></p>
- <%= link_to "I'm interested", post_path(post.id), class: 'interested' %>
- </div>
- </div>
- </div><!-- card -->
- </div><!-- col-sm-3 -->
- #pages_controller.rb
- class PagesController < ApplicationController
- def index
- end
- end
- #index.html.erb located app/views/pages/
- <div class="container-fluid">
- <div class="row">
- <div class="col-sm-3" id="side-menu">
- </div><!-- side menu -->
- <div class="col-sm-9" id="main-content">
- </div><!-- main content -->
- </div><!-- row -->
- </div>
- #routes.rb
- Rails.application.routes.draw do
- devise_for :users,
- :controllers => {:registrations => "registrations"},
- path: '',
- path_names: {
- sign_in: 'login',
- sign_out: 'logout',
- password: 'secret',
- sign_up: 'register'
- }
- resources :posts do
- collection do
- get 'hobby'
- get 'study'
- get 'team'
- end
- end
- root to: 'pages#index'
- # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement