Question are at end of the topic.
class Product ActiveRecord::Base
belongs_to :categoriesend
class Category ActiveRecord::Base
has_many :productsend
Categories table has 2 level nesting, for example.
Main category is 'Men', sub-category is 'Accessories' and sub-sub-category is
I have 3 models:
class Product ActiveRecord::Base
has_many :product_option_types
has_many :option_types, through: :product_option_typesend
class OptionType ActiveRecord::Base
has_many :product_option_types
has_many :products, through: :product_option_typesend
class
Trying to implement web service in rails through API sub-domain called
api.
In my hosts file i added line: 127.0.0.1 api.localhost
In my routes.rb i set sub-domain, where i only need index action and few
manually added restful routes, through following:
namespace :api, path: '', :constraints
So resources :products will create 7 different restful routes for CRUD
operations for resource products.
For example: products GET /products(.:format) products#index
So restful route includes only controller name within itself and :id for
operation like edit, show, update, delete.
When i
So resources :products will create 7 different restful routes for CRUD
operations for resource products.
For example: products GET /products(.:format) products#index
So restful route includes only controller name within itself and :id for
operation like edit, show, update, delete.
When i
Thanks Colin on reply. I tried with following code, which work good but i
don't know how to create row in *votes* table.
*// routes.rb*
resources :entries, :only =[:new, :create]
//* entries_controller.rb*
class EntriesController ApplicationController
def new
@entry = Entry.new(*:user_id
Thanks Colin on reply. I tried with following code, which work good so just
wanted to ask is this correct solution, for some reason i think this code
smell.
*// routes.rb*
resources :entries, :only =[:new, :create]
*// user.rb*
class User ActiveRecord::Base
has_many :entries
end
*//
I have following tables with following models:
users(id, role_id) *has_many :entries*
categories(id, category_name) *has_many :entries*
entries(id, category_id, user_id) *belongs_to :user, belongs_to
:category, has_one :storage*
storages(id, title, content, entry_id)*
In application user can enter new *post* which contain *title*, *content*of the
post and
*category* of post. So creating new post will be through some simple html
form with few fields. Now i don't know where to put logic for creating new
post for following reasons:
Post(or posts
Hy,
I have some table in my DB like following: *Post(id, title, content,
created_at, updated_at)*
First question, what type ActiveRecord returns?
For example if i do something like: @posts = Post.all, through debugger i
can see:
#ActiveRecord::Relation
*[*#Post id: 1, title: My first post,
10 matches
Mail list logo