My tables repeat this line always
property :created_at, DateTime, :default => DateTime.now, :lazy => [:show]
property :updated_at, DateTime, :default => DateTime.now, :lazy => [:show]
How do I DRY this out? Do I inherit, or have a module, or something else?
It's like this:
Class Foo
include DataMapper::Resource
property :id, Int
property :created_at, DateTime, :default => DateTime.now, :lazy => [:show]
property :updated_at, DateTime, :default => DateTime.now, :lazy => [:show]
end
Class Bar
include DataMapper::Resource
property :id, Int
property :created_at, DateTime, :default => DateTime.now, :lazy => [:show]
property :updated_at, DateTime, :default => DateTime.now, :lazy => [:show]
end
these are repeated multiple times through each of the table
Well, now I understand what you are saying. Those are rails properties, which are created automatically. I'm not sure if there's a way of preventing this from happening, but those are definitely useful in many situations. I suggest you keep them, you will figure out their use as you learn more about Rails.
As for the views, you need to create a controller method and define a route to those methods inside config/routes.rb
. I suggest you learn more about the MVC rails pattern. MVC is the core in which Rails is built upon.
http://guides.rubyonrails.org/ is a great website for learning rails. Try reading just a few articles and you'll be able to understand enough to build a full application in no time.