Created
July 23, 2011 03:15
-
-
Save elricstorm/1100923 to your computer and use it in GitHub Desktop.
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
<% @data.each do |data| %> | |
<p><%= data.something %></p> | |
<p><%= data.something_else %></p> | |
<% 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
class ExampleController < ApplicationController | |
respond_to :html, :xml | |
before_filter :set_tables | |
def set_tables | |
@tables = ['example_model'] | |
end | |
def index | |
if @tables.include?(params[:table_index]) | |
@data = params[:table_index].singularize.camelize.constantize.list_data | |
@partial = params[:table_index] | |
respond_with @data | |
else | |
redirect_to root_url, :notice => 'You are trying to access a page that does not exist. Please check the URL and try again.' and return false | |
end | |
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
class ExampleModel < ActiveRecord::Base | |
# you can add model relationships here, and add default scopes | |
# default_scope :order => 'someColumn ASC' | |
def self.list_data | |
return self.where(somedata = ? and otherdata = ?', somedata, otherdata) | |
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
<%= render @partial %> |
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
YourApplication::Application.routes.draw do | |
match '/example/:table_index' => 'example#index', :as => 'default_table' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment