adds legislations
This commit is contained in:
8
app/controllers/legislations_controller.rb
Normal file
8
app/controllers/legislations_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class LegislationsController < ApplicationController
|
||||||
|
load_and_authorize_resource
|
||||||
|
|
||||||
|
def show
|
||||||
|
@legislation = Legislation.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
class Annotation < ActiveRecord::Base
|
class Annotation < ActiveRecord::Base
|
||||||
serialize :ranges, Array
|
serialize :ranges, Array
|
||||||
|
|
||||||
belongs_to :proposal
|
belongs_to :legislation
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
end
|
end
|
||||||
3
app/models/legislation.rb
Normal file
3
app/models/legislation.rb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
class Legislation < ActiveRecord::Base
|
||||||
|
has_many :annotations
|
||||||
|
end
|
||||||
10
app/views/legislations/show.html.erb
Normal file
10
app/views/legislations/show.html.erb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<% if current_user %>
|
||||||
|
<section class="annotate" data-id=<%= @legislation.id %> data-user-id=<%= current_user.id %>>
|
||||||
|
<% else %>
|
||||||
|
<section>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div><%= @legislation.title %></div>
|
||||||
|
<div><%= @legislation.body %></div>
|
||||||
|
|
||||||
|
</section>
|
||||||
@@ -61,6 +61,8 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :legislations, only: [:show]
|
||||||
|
|
||||||
resources :annotations do
|
resources :annotations do
|
||||||
collection do
|
collection do
|
||||||
get :search
|
get :search
|
||||||
|
|||||||
10
db/migrate/20151215113827_create_legislations.rb
Normal file
10
db/migrate/20151215113827_create_legislations.rb
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
class CreateLegislations < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :legislations do |t|
|
||||||
|
t.string :title
|
||||||
|
t.text :body
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -181,6 +181,13 @@ ActiveRecord::Schema.define(version: 20151118160928) do
|
|||||||
|
|
||||||
add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree
|
add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree
|
||||||
|
|
||||||
|
create_table "legislations", force: :cascade do |t|
|
||||||
|
t.string "title"
|
||||||
|
t.text "body"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "locks", force: :cascade do |t|
|
create_table "locks", force: :cascade do |t|
|
||||||
t.integer "user_id"
|
t.integer "user_id"
|
||||||
t.integer "tries", default: 0
|
t.integer "tries", default: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user