Last active
August 29, 2015 14:23
-
-
Save sebastjan-hribar/4eb19a978ec6042781ff to your computer and use it in GitHub Desktop.
change_action
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'camping' | |
Camping.goes :People | |
module People::Controllers | |
class Index < R '/' | |
def get | |
render :index | |
end | |
end | |
class PersonNew | |
def get | |
render :new_person | |
end | |
def post | |
render :from_post | |
end | |
end | |
class PersonSearch | |
def get | |
end | |
def post | |
render :from_search | |
end | |
end | |
end | |
module People::Views | |
def layout | |
html do | |
head do | |
title 'Using JQuery in Camping' | |
script :src => 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', :type => 'text/javascript' | |
script :type => 'text/javascript' do " | |
$(document).ready(function() { | |
$('#ter').click(function(){ | |
$('#form1').attr('action', 'search'); | |
}); | |
});" | |
end | |
end | |
body { self << yield } | |
end | |
end | |
def index | |
h1 "Start" | |
a "New person", href: R(PersonNew) | |
end | |
def new_person | |
h2 "Create new person" | |
hr | |
_form(action: R(PersonNew)) | |
end | |
def from_post | |
h2 "Got here from post" | |
a "Back", href: R(Index) | |
end | |
def from_search | |
h2 "Got here from search" | |
a "Back", href: R(Index) | |
end | |
end | |
def _form(route) | |
form.form1! route, method: 'post' do | |
label "First name: ", for: 'first_name' | |
input type: 'text', name: 'first_name' | |
label "Last name: ", for: 'last_name' | |
input type: 'text', name: 'last_name' | |
input type: 'submit', value: "From post" | |
input.ter! type: 'submit', value: "Search" | |
end | |
end | |
def People.create | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment