adds legislations

This commit is contained in:
rgarcia
2015-12-15 13:08:03 +01:00
parent dea9110a69
commit 996e87cb13
7 changed files with 41 additions and 1 deletions

View File

@@ -0,0 +1,8 @@
class LegislationsController < ApplicationController
load_and_authorize_resource
def show
@legislation = Legislation.find(params[:id])
end
end

View File

@@ -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

View File

@@ -0,0 +1,3 @@
class Legislation < ActiveRecord::Base
has_many :annotations
end

View 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>

View File

@@ -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

View 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

View File

@@ -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