Skip to content

Commit

Permalink
Welcome Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
thiagopradi committed Jul 12, 2010
1 parent 7cb524f commit 8a0ba76
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 285 deletions.
1 change: 1 addition & 0 deletions README.mkdn
Expand Up @@ -5,6 +5,7 @@
<h2>Feature list: </h2>

<p> All writes will be sent to master, and the read queries will be sent to the slaves. unless you have a transaction, so , all queries will be sent to master.</p>
<p> The application have two different models: Client and User. User is a replicated model, and Client isn't replicated. So, when you create a new User, you will see a exception, because you don't have configuration for replication and Rails tries to read the user from a slave database, and the write query have been sent to master (Default behaviour when using replication). When you create a new client, everything should works fine, it will read and write in the master database. </p>

<h2> Setup: </h2>
<p> You will need two commands to setup the application:</p>
Expand Down
4 changes: 4 additions & 0 deletions app/controllers/welcome_controller.rb
@@ -0,0 +1,4 @@
class WelcomeController < ApplicationController
def index
end
end
2 changes: 2 additions & 0 deletions app/helpers/welcome_helper.rb
@@ -0,0 +1,2 @@
module WelcomeHelper
end
6 changes: 6 additions & 0 deletions app/views/welcome/index.html.erb
@@ -0,0 +1,6 @@
<h1>Welcome to Octopus Replication Example!</h1>
<p>Replicated Model:</p>
<%= link_to "Users", users_path%>
<p>Non-Replicated Model:</p>
<%= link_to "Clients", clients_path%>

6 changes: 2 additions & 4 deletions config/routes.rb
@@ -1,8 +1,8 @@
OctopusReplicationExample::Application.routes.draw do |map|
get "welcome/index"
resources :clients

resources :users

root :to => "welcome#index"
# The priority is based upon order of creation:
# first created -> highest priority.

Expand Down Expand Up @@ -49,10 +49,8 @@
# # (app/controllers/admin/products_controller.rb)
# resources :products
# end

# You can have the root of your site routed with "root"
# just remember to delete public/index.html.
# root :to => "welcome#index"

# See how all your routes lay out with "rake routes"

Expand Down
6 changes: 4 additions & 2 deletions db/schema.rb
Expand Up @@ -11,14 +11,16 @@

ActiveRecord::Schema.define(:version => 20100623041305) do

create_table "clients", :force => true do |t|
create_table "clients", :id => false, :force => true do |t|
t.integer "id", :null => false
t.string "name"
t.date "birthday"
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "users", :force => true do |t|
create_table "users", :id => false, :force => true do |t|
t.integer "id", :null => false
t.string "name"
t.date "birthday"
t.datetime "created_at"
Expand Down
279 changes: 0 additions & 279 deletions public/index.html

This file was deleted.

12 changes: 12 additions & 0 deletions spec/controllers/welcome_controller_spec.rb
@@ -0,0 +1,12 @@
require 'spec_helper'

describe WelcomeController do

describe "GET 'index'" do
it "should be successful" do
get 'index'
response.should be_success
end
end

end
15 changes: 15 additions & 0 deletions spec/helpers/welcome_helper_spec.rb
@@ -0,0 +1,15 @@
require 'spec_helper'

# Specs in this file have access to a helper object that includes
# the WelcomeHelper. For example:
#
# describe WelcomeHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe WelcomeHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
5 changes: 5 additions & 0 deletions spec/views/welcome/index.html.erb_spec.rb
@@ -0,0 +1,5 @@
require 'spec_helper'

describe "welcome/index.html.erb" do
pending "add some examples to (or delete) #{__FILE__}"
end

0 comments on commit 8a0ba76

Please sign in to comment.