Advertisement
Guest User

Untitled

a guest
Aug 11th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.59 KB | None | 0 0
  1. #posts_controller.rb
  2. class PostsController < ApplicationController
  3.   def index
  4.     @post = Post.limit(5)
  5.   end
  6. end
  7.  
  8. #_post.html.erb located app/views/posts
  9. <div class="col-sm-3 single-post-card" id=<%= post_path(post.id) %>>
  10.   <div class="card">
  11.     <div class="card-block">
  12.       <h4 class="post-text">
  13.         <%= truncate(post.title, :length => 60) %>
  14.       </h4>
  15.       <div class="post-content">
  16.         <div class="posted-by">Posted by <%= post.user.name %></div>
  17.         <h3><%= post.title %></h3>
  18.         <p><%= post.content %></p>
  19.         <%= link_to "I'm interested", post_path(post.id), class: 'interested' %>
  20.       </div>
  21.     </div>
  22.   </div><!-- card -->
  23. </div><!-- col-sm-3 -->
  24.  
  25. #pages_controller.rb
  26. class PagesController < ApplicationController
  27.   def index
  28.   end
  29. end
  30.  
  31. #index.html.erb located app/views/pages/
  32. <div class="container-fluid">
  33.   <div class="row">
  34.    
  35.     <div class="col-sm-3" id="side-menu">
  36.     </div><!-- side menu -->
  37.  
  38.     <div class="col-sm-9" id="main-content">
  39.     </div><!-- main content -->
  40.  
  41.   </div><!-- row -->
  42. </div>
  43.  
  44. #routes.rb
  45. Rails.application.routes.draw do
  46.   devise_for :users,
  47.     :controllers => {:registrations => "registrations"},
  48.     path: '',
  49.     path_names: {
  50.       sign_in: 'login',
  51.       sign_out: 'logout',
  52.       password: 'secret',
  53.       sign_up: 'register'
  54.     }
  55.  
  56.   resources :posts do
  57.     collection do
  58.       get 'hobby'
  59.       get 'study'
  60.       get 'team'
  61.     end
  62.   end
  63.  
  64.   root to: 'pages#index'
  65.   # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
  66. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement