mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-02-03 15:01:11 +00:00
Create stubs for controller and model
This commit is contained in:
parent
756285cebe
commit
6b334ced39
6 changed files with 48 additions and 0 deletions
3
app/assets/javascripts/sites.js.coffee
Normal file
3
app/assets/javascripts/sites.js.coffee
Normal 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/
|
16
app/controllers/sites_controller.rb
Normal file
16
app/controllers/sites_controller.rb
Normal 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
9
app/models/site.rb
Normal 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
|
2
app/views/sites/administrate.html.erb
Normal file
2
app/views/sites/administrate.html.erb
Normal file
|
@ -0,0 +1,2 @@
|
|||
<h1>Site#administrate</h1>
|
||||
<p>Find me in app/views/site/administrate.html.erb</p>
|
|
@ -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"
|
||||
|
|
12
db/migrate/20171109165433_create_sites.rb
Normal file
12
db/migrate/20171109165433_create_sites.rb
Normal 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
|
Loading…
Reference in a new issue