-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing quick graphs! Migration needed.
- Loading branch information
Lennart Koopmann
committed
Dec 25, 2009
1 parent
0da0d02
commit a59bcfb
Showing
18 changed files
with
322 additions
and
16 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
class TopgraphsController < ApplicationController | ||
def create | ||
graph = Topgraph.new params[:topgraph] | ||
graph.user_id = current_user.id | ||
|
||
if graph.save | ||
flash[:notice] = "Quick graph has been created." | ||
else | ||
flash[:error] = "Could not create quick graph!" | ||
end | ||
|
||
redirect_to :controller => "users", :action => :settings | ||
end | ||
|
||
def destroy | ||
graph = Topgraph.find params[:id] | ||
|
||
if graph.delete | ||
flash[:notice] = "Quick graph has been deleted." | ||
else | ||
flash[:error] = "Could not delete quick graph!" | ||
end | ||
|
||
redirect_to :controller => "users", :action => :settings | ||
end | ||
|
||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module TopgraphsHelper | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Topgraph < ActiveRecord::Base | ||
validates_presence_of :graph_type, :target_id, :name, :minutes | ||
validates_numericality_of :graph_type, :target_id, :minutes | ||
|
||
validates_length_of :name, :maximum => 5 | ||
end |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class CreateTopgraphs < ActiveRecord::Migration | ||
def self.up | ||
create_table :topgraphs do |t| | ||
t.integer :type | ||
t.integer :target_id | ||
t.string :target_sensor | ||
t.string :name | ||
t.integer :minutes | ||
t.timestamps | ||
end | ||
end | ||
|
||
def self.down | ||
drop_table :topgraphs | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
db/migrate/20091225001520_change_topgraph_type_column_name.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class ChangeTopgraphTypeColumnName < ActiveRecord::Migration | ||
def self.up | ||
rename_column :topgraphs, :type, :graph_type | ||
end | ||
|
||
def self.down | ||
rename_column :topgraphs, :graph_type, :type | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
class AddUserIdToTopgraphs < ActiveRecord::Migration | ||
def self.up | ||
add_column :topgraphs, :user_id, :integer | ||
end | ||
|
||
def self.down | ||
remove_column :topgraphs, :user_id | ||
end | ||
end |
Oops, something went wrong.