Create stubs for controller and model

This commit is contained in:
Absurdon 2017-11-09 18:25:52 +01:00 committed by Absurdon
parent 756285cebe
commit 6b334ced39
6 changed files with 48 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

View file

@ -0,0 +1,16 @@
class SitesController < ApplicationController
def administrate
end
def create
end
def show
end
def update
end
def destroy
end
end

9
app/models/site.rb Normal file
View file

@ -0,0 +1,9 @@
class Site < ActiveRecord::Base
belongs_to :article
attr_accessible :name
validates :name,
length: {in: 2..10},
uniqueness: true,
format: /\A[a-z\-]{2,10}\Z/
end

View file

@ -0,0 +1,2 @@
<h1>Site#administrate</h1>
<p>Find me in app/views/site/administrate.html.erb</p>

View file

@ -1,4 +1,5 @@
Ensl::Application.routes.draw do
%w(403 404 422 500).each do |code|
get code, to: "errors#show", code: code
end
@ -135,6 +136,11 @@ Ensl::Application.routes.draw do
match "votes/create"
match "polls/showvotes/:id", to: "polls#showvotes", as: "polls_showvotes"
get "sites/administrate"
resource :sites, only: [:create, :update, :destroy]
get ":name", requirements: {name: /\A[a-z\-]{2,10}\Z/}
match ":controller/:action", requirements: { action: /A-Za-z/ }
match ":controller/:action/:id"
match ":controller/:action/:id.:format"

View file

@ -0,0 +1,12 @@
class CreateSites < ActiveRecord::Migration
def change
create_table :sites do |t|
t.string :name
t.references :article
t.timestamps
end
add_index :sites, :name
add_index :sites, :article_id
end
end