similar to: Best practices for handling associations in ctrlrs/views

Displaying 20 results from an estimated 5000 matches similar to: "Best practices for handling associations in ctrlrs/views"

2007 Sep 08
2
"Common action" for a controller
Sorry if this has been asked before; it seems like a simple problem. I have a controller called ItemController which displays information about specific items to a user on various pages. The routing looks like "items/:item/:action". Is there any way to automatically look up the :item in the items table (it''s just an ID). I tried: before_filter { @current_item =
2006 Jul 27
0
CRUD, REST and associations
Let''s say I have the model class Reader and Magazine, connected by join model Subscription. It looks something like this class Reader < ActiveRecord::Base has_many :subscriptions, :dependent => :delete_all has_many :magazines, :through => :subscriptions validates_presence_of :name end class Magazine < ActiveRecord::Base has_many :subscriptions, :dependent =>
2005 Oct 15
1
Partials and controllers
Newbie question: From a _form.rhtml file I have: <%= render(:partial => ''item'', :collection => @items) %> In _item.rhtml I have: <% @tullt = h(item.body) %> <%= @itemdb = Group.find(:all, :conditions => "id = ''#{@tullt}''").map {|u| [u.name] } %> <%= @tullt % I think it would be better to
2006 Aug 02
0
Composite Primary Keys support for Associations
Announcement: Composite Primary Keys gem now includes support for ActiveRecord Associations. Summary: Composite Primary Keys allows an ActiveRecord to support 2+ primary keys using the set_primary_keys class method. Previous versions provided full CRUD and find support. This latest release provides support for more ActiveRecord magic: associations (has_many, belongs_to, etc) Full report:
2007 Oct 06
4
spec''ing views, mock_model associations
I writing a spec that returns the count of how many players in a game: it "should how many players in a link to all players" do render :partial =>"games/game", :object => @game response.should have_tag(''a'',"(2) Players") end I''m not sure how to do the mock model, I think it would be done two ways but unsure of the syntax: 1: add
2006 Feb 10
0
ajax form submission and updating multiple divs
I''m not sure if this is even possible, but here is my current method: class Item < ActiveRecord::Base def self.generate(name) Item.create(:name => name) || nil end end class ItemController < ActionController::Base layout "application" def index @items = Item.find(:all) end def create if @request.method ==:post name = @params[:name]
2006 Apr 04
2
Sharing controller code between views - best practices?
Hi, I have controller code that needs to be shared between multiple different user type views and want to know what is considered ''best practice'' or what other people are doing out there. Example: I have admin users, salesperson users, and possibly another type of user. They all need code to add/edit/delete a property - and other abilities. The code would be identical(in
2006 Mar 24
0
merging models/views with scaffolding
Allo, Just started playing around with RoR/scaffolding and have been impressed so far. However, it seems to create a 1:1 relationship between Controllers and Models and the basic CRUD actions -- I need to CRUD two models from the same views and actions. I have: Book model Book controller, with create/edit/show/destroy/list actions and the scaffold-gen''ed views. Category model Category
2006 Jan 15
2
new objects and new associations in same view
Hello All, I generated scaffolding for my Users table and setup my additional models with their associations. I want to be able to create a new user, and its associated groups and privileges from the same view. My relationships are as follows: users: has_and_belongs_to_many :groups has_many :privileges groups: has_and_belongs_to_many :users privileges: belongs_to :user Right
2008 Oct 14
2
best-practice for programmatically using rxml generated from controller/view? (or 'how can I view a view from a model')
Hey Guys, Here''s the scenario: I''ve got vendor-specific XML I need to create and then POST it somewhere. It sounds easy enough, but I''m running into issues when it comes time to actually use the XML. Trying hard to stay within the MVC pattern I: 1) Create a controller which loads the models I''m about to turn into XML 2) Create an rxml view which renders the
2006 Mar 03
7
Best Practices question regarding views & controllers
Hi List! I''m reading the Agile book, as many online articles as I can, but there''s still some things that are just too hard to answer for yourself. In building my application, I often find myself putting code into my views of which I am not quite certain it belongs there. Where do you usually draw the line? Is it okay to, say, loop through an array of hashes that represents
2005 Apr 27
2
noob question: rhtml new/edit views and the date functionality
Hello All, I''ve been playing with Rails - did the recipe/category sample from onLamp.com - fairly straight forward - even got it working against postgres. Anyway, I''ve been appling rails to a small test project and I can''t seem to get the syntax down or find a sample of how to use the date control on a custom new/edit view. The CRUD (is that right?) that automatically
2013 Jul 09
1
tips/nest practices for gluster rdma?
Hey guys, So, we're testing Gluster RDMA storage, and are having some issues. Things are working...just not as we expected them. THere isn't a whole lot in the way, that I've foudn on docs for gluster rdma, aside from basically "install gluster-rdma", create a volume with transport=rdma, and mount w/ transport=rdma.... I've done that...and the IB fabric is known to be
2009 Sep 12
3
Need help on Many to Many Relationships
Hi, Does anyone know where I can find a full step by step tutorial on Many to Many Relationships with Rails or can describe the steps in inserting data into the join tables, displaying the connections, etc.. - I don''t only need the model, but all the steps that you would use in the MVC architecture to make it work. I am a new to Rails and I cannot find a complete tutorial on all the
2017 May 17
0
Best practices for copying lots of files machine-to-machine
On 05/17/2017 12:03 PM, ken wrote: > An entire filesystem (~180g) needs to be copied from one local linux > machine to another. Since both systems are on the same local subnet, > there's no need for encryption. > > I've done this sort of thing before a few times in the past in > different ways, but wanted to get input from others on what's worked > best for
2006 Aug 03
5
DRYing up the view
Hello everyone! I have generic views for CRUD operations For example I render(''shared/list'') from controller shared/list.rhtml ... <% for item in @list %> <tr class="<%= cycle ''list-line-odd'', ''list-line-even'' %>"> <%= render :partial => ''item'', :locals => { :item => item } %>
2006 Jul 24
8
Views in one controller reaching out to other controllers (best practices)
Hello all. For the purpose of my question, let''s imagine we''re building some search functionality. You''re a sales person (you poor sap). And you''re hanging out in the SalesCenterController. You need to do a search for available productions; you''ve decided to be cool and use Ajax. Do you... a) Make a remote call to an action in your current controller
2006 Oct 16
0
Restful routes, not repeating yourself and non-standard rest actions best practices
So I''ve recently started playing with the restful routes support in edge rails, converting a few of my controllers to support all the standard operations.. One thing that''s been bothering me, however, is the following: Before using restul routes, I would define an edit method in my controller which would be responsible for both creating new objects as well as editing
2006 Mar 28
5
combining two models in one controller/view "set"
I''m going to take another stab at this question (my first one received no replies): I have two models: Author has_many: books Book has_one: author I have two tables: authors id ... books id author_id ... I let the scaffolding fly and it created the CRUD goodness for each model, as expected. However, I want to have only one view/controller "set" for both models; when I
2006 May 26
9
What syntax is this? belongs_to :Person
so when I''m reading the pick axe book second edition I don''t see anything like the syntax you see people using in rails code. Specifically when you see. belongs_to :Person has_many :Phones etc these are methods on ActiveRecord right? Why is this invocation syntax never described in the Pick Axe book? I do see things like attr_reader :some_attribute etc but you