Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<% @data.each do |data| %>
<p><%= data.something %></p>
<p><%= data.something_else %></p>
<% end %>
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
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
<%= render @partial %>
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