search for: content_columns

Displaying 20 results from an estimated 79 matches for "content_columns".

2006 Jan 03
0
Automatically mapping content_columns?
Hi all, Quick setup - I''ve got a table Foo. Foo has a foreign key (bar_id) to the table Bar. The Bar table has an "id" and "name" column. Assume a 1:1 relationship. The issue I''m trying to resolve (or rather, be lazy about) is with regards to Foo.content_columns. By default it doesn''t pickup the foreign key. What I''m wondering is if there''s a convenient way to have content_columns automatically pick up both the column name and value that I''m after in the parent table. Or is that just something I have to work out man...
2006 Feb 03
1
Only iterating over the middle content_columns?
Standard behavior for the list action is to use content_columns to get all the fields of a model and then do something with them. I''d like to ignore some of them and iteratre over the rest. For instance I may have A B C D ... X Y Z and I''d like to do something special with A and B and then Y and Z, but in the middle I''d definit...
2006 Mar 03
0
Does content_columns hold related data from other tables?
I''ve got a belongs_to / has_many relationship working, however I don''t know if I can still use content_columns (or any other shortcut) in my view that displays my object. E.g., Employee belongs_to Department I''m displaying an Employee. Will content_columns contain employee.department.name? Or how else could I do this so I don''t have to hard-code column references that could change la...
2006 Jan 30
1
how to get column_for_attribute?
Hi all, In the code below I don''t understand: 1. Why I have to prepend overriden method content_columns with "self." to get it working? 2. Why column_for_attribute method is not working (no such method?) even if SomeTable is subclass of ActiveRecord::Base which have public column_for_attribute method? > class SomeTable < ActiveRecord::Base > > def self.content_columns >...
2007 Mar 14
0
#content_column and polymorphic columns
Hi ! I'm need to use ActiveRecord::Base#content_columns, but this method does not filter out columns suffixed with _type, which is what polymorphism uses. I checked the 1.2 branch and trunk, and both don't do it: http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/base.rb#L810 Is that considered a bug ? I'll whip up a test...
2006 Mar 22
3
Something wrong with content_columns
I have a database with a couple of tables. One table called spares has foreign keys in another called equipment. When I create a new record, it is added to the spares table however the list action does not show all the columns in the table. It only shows those columns that are not foreign keys. I am using the default action generated by scaffold for list. Why is that so? Do i need to re-write my
2006 Apr 27
2
"for column in..." not picking up _id columns
My code executes fully: <% for column in ModelName.content_columns %> <th><%= column.human_name %></th> <% end %> but it does not pick up any columns in my model''s table that end in "_id". Is this by design? Is there a helper method that will reference the related tables? Or will I need to code the column t...
2006 Aug 18
3
Understanding MVC - view customization after using scaffolds
...r, and view. My question is if I want to only allow a user to see certain information in the list and only be able to add new information to certain fields where do I begin? I look at my list.rhtml for customerinfo and see the following (after some other html): <% for column in Customer.content_columns %> <td><%=h customer.send(column.name) %></td> <% end %> I realize this is what prints out each line, but how do I begin specifying only certain columns to be printed? I guess I don''t understand the customer.send(column.name). If someone has a good tu...
2005 Dec 30
3
Too many columns for list.rhtml to display on one page
...rn a handfull of columns to the screen? I think I do it in the view (list.rhtml - excerpted below). Does anyone have an example that only prints out a subset of the columns in a table? .......... <h1>Listing volunteers</h1> <table> <tr> <% for column in Volunteer.content_columns %> <th><%= column.human_name %></th> <% end %> </tr> ............ -- Posted via http://www.ruby-forum.com/.
2006 Feb 01
4
Where is the send() function?
Hi, in the tutorial "4 Days on Rails" the following code fragment is used: ,---- | <% for column in Category.content_columns %> | <td><%=h category.send(column.name) %></td> | <% end %> `---- Apparently, the send() function returns the column value by name, but where does this function comes from? Unfortunately, neither the tutorial nor the API documentation tell it. -- \ /...
2006 Aug 07
8
Syntax Problem
In an *.rhtml, why do I need to add <% for product in @products %> in order that I may call an <img class="list-image" src="<%= product.img_url %>"/>. Is there not another way to skip the "for product" line? I really dont want to include it. I tried @products = product but it does not work. Can anyone help shed light on this matter? -- Posted via
2005 Sep 17
1
Export to Excel
...d to export some data to an Excel file and found a reference in the HowTo section of the Rails Wiki. Followed it to the letter: added "export" action to controller, copied export.rxml and changed in accordance to model. When I call the export action I keep getting "undefined method `content_columns'' for #<Employee". The ActiveRecord mention content_columns but the error page says that it cannot be found. Suggestions? -- PC __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.co...
2006 Mar 14
4
What does the send() method do on a model object?
All, I did a scaffold for a model and I ended up with this code in list.rhtml: <% for column in TargetList.content_columns %> <td><%=h target_list.send(column.name) %></td> <% end %> Where is the "send" method and what does it do? I can''t find it on ActiveRecord::Base? I assume that it returns a value based on the column id but I can''t find any documenta...
2006 Jan 25
1
Rails day 2: where is my association?
...`group_id` INT( 255 ) NOT NULL , `package_id` INT( 255 ) NOT NULL , PRIMARY KEY ( `id` ) ) TYPE = innodb; class Group < ActiveRecord::Base has_many :packages end class Package < ActiveRecord::Base belongs_to :group end now the default scaffold list.rhtml has <% for column in Package.content_columns %> <td><%=h package.send(column.name) %></td> <% end %> this won?t show the group_id but this will <% @packages.each do |package| %> <td><%= link_to package.name, :action => "show", :id => package.id %></td> <td&...
2008 Mar 15
9
Spaces in Ruby on Rails and how to avoid them!
Hi, I just started learning ruby on rails and I am having hard time with white spacing! Here is the piece of code that will not work: validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message => "must be a URL for a GIF, JPG or PNG image" and here is the piece of code that will work: validates_format_of :image_url, :with => %r{\.(gif|jpg|png)$}i, :message
2008 Mar 12
3
undefined method `each' for #<Usrecart:0x46d1678>
...FILE</h2> <%@usercart=Usrecart.find_by_user_id(@b)%> <%if @usercart.blank?%> <br> <br> <br> <br> <h2>THERE IS NO PRODUCT</h2> <%end%> <%if !@usercart.blank?%> <% for u in @usercart %> <% for column in u.content_columns %> <%=h u.send(column.name) %> <%end%> <%end%> <%=@usercart.user_id%> <%end%> <%=link_to "ADD NEW ITEM",:action=>''index'',:id=>@usercart.user_id%> </center> --~--~---------~--~----~------------...
2006 Jan 28
3
DRY conflict with "Updated at" "Created at" "Deleted at" in view
Hi all, Are there any helpers or so for listview routines that suppres the three above mentioned columns? I''m currently exploring something like the code below. But it feels like I''m doing Rails'' work. # just for test purposes <div id="debug"> <% for col in Product.columns.map %> <%= col.name %> - <%= col.type %><br/> <%
2006 Jan 23
5
Bibtex database design
...k but in the view part I want to create a form that would display certain fields based on the publication type. For example Article has some required, optional and ignored fields. I want the view (Create/Edit) to show only those attributes relevant to a publication class. I tried overriding the content_columns but in console I get a stack too deep error or segfaults sometimes. I tried this class Article < Publication validates_presence_of :title, :journal, :year def self.content_columns return Article.content_columns.delete_if {|c| ["publisher"].include?(...
2006 Mar 08
2
Displaying related tables in forms.. probably an easy question!
...g: property.rb - has_one :PropertyType property_type.rb - has_many :Properties property_controller - def list @property_pages, @properties = paginate :properties, :per_page => 10 end list.html: 1. <% for property in @properties %> 2. <tr> 3. <% for column in Property.content_columns %> 4. <td> 5. <%=h property.send(column.name) %> 6. </td> 7. <% end %> 8. <td><%=h property.propertytype.name %></td> 9. <% end %> Two questions: 1) I get an error stating that I am trying to reference the propertytype...
2005 Dec 31
7
Dynamic form? Not really!
...mpanies.each do |company| %> <option value="<%= company.id %>"> <%= company.name %> </option> <% end %> </select> </td></tr> ### The cool dynamic part that shows the rest <% odd_or_even = 0 for column in Contact.content_columns odd_or_even = 1 - odd_or_even %> <tr class="ListLine<%= odd_or_even %>"> <td><%= column.human_name %>:</td> <td><%= text_field ''contact'', column.name %></td> </tr> <% end %> </table> <inp...