Displaying 20 results from an estimated 5000 matches similar to: "strange MySQL data populating"
2006 May 12
11
Stupid? question about if else logic
this seems so stupid, I keep thinking I''ve dealt with this before but I
have this code
<h1>Portraits</h1>
<% if @image.portrait == 1 %>
<%= image_tag(url_for_file_column ''image'', ''file'', ''thumb'') %>
<% else %>
<h1>Landscapes</h1>
<%= image_tag(url_for_file_column
2006 Jan 14
0
Compact db design a bad idea?
Hi,
I have tried two db designs and both can work but I wonder which one
the Rails Gurus would go with. This is a general db design question
that has cropped up in a few situation. Here is the example I''ve been
working on.
In an online store, categories has_and_belongs_to_many images and
products has_and_belongs_to_many images. The db has the basic three
tables
categories
- id
- name
2006 Jul 12
1
odd habtm behavior? or is it me?
Hello List,
I''m a bit spent on this problem, and my code might be whack. I seem to be
encountering a problem where the primary key on a join table is not being
resolved correctly. I will elaborate after some code bits. I am creating
the join table using migrations, and relevant model code is this:
class Post < ActiveRecord::Base
has_and_belongs_to_many :records
2006 Jun 28
0
habtm and multiple-option select boxes
I''ve got a fairly basic has_and_belongs_to_many setup, with a Business
model and a Category model. In the admin functionality for the Business,
I''d like to have a multiple select box showing all of the Categories, with
included ones selected, etc.
I''m stumped as to how to do it, though - it seems like there should be an
easy way, but I''m missing it looking
2006 Mar 30
5
Heeelp - no idea what''s going wrong.
I''m working on a simple CMS. The main data type are "listings" a listing
habtm (has_and_belongs_to_many) categories and subcategories.
Subcategories belong_to categories. Subcategories are basically the same
as categories, but they are treated differently in a few situations.
The problem is, I can''t seem to write the view/controller/model code
that allows me to
2006 Jul 18
0
another 2 newbie questions
Hey all,
Ok I have three tables:
Images(id,name,dirid) #dirid is a foreign key to Album.url, the path
to the image
Albums(id,url)
Tags(id,name)
ImagesTags(image_id,tag_id)
I have a HABTM relation for tags and images and a belongs_to/has_many
relation for albums and images.
Now in my views/tag/show.rhtml I have this:
<% for album in @albums %>
<% for image in @images %>
<% if
2006 Jun 07
1
How do YOU read/update HABTM?
In my mind, it should work like this:
<%= select ''item'',
''category_ids'',
Category.find(:all).collect {|c| [c.name, c.id] },
{},
{:multiple=>true, :size=>20} %>
Then Rails should automatically populate and update HABTM on that. As it
is now, the above won''t work (I created a getter in item''s model that
returns an array of
2006 Jun 05
5
adding habtm through migrations
Hello,
I''m stuck, I''ve got a model Product and would like to add a new model
called Category. Furthermore, I want to set up a many2many
relationship between the mentioned models. the problem is that I do
not know how to set the primary key in the categories_products table.
this is what I''ve got in my migration file:
create_table :categories do |t|
t.column :name,
2012 Jul 18
0
Rails 3.1 Optional Routes
Hi all,
I am using Rails 3.1 and Ruby 1.9.2
In my application i am using optional routes like below
match ''Gallery(/:gallery_id(/:image_id))(/page/:g_page)'' => "wps/
gallery#show_gallery_page",:as => :gallery_page
in console i am trying to call the routes like below
include Rails.application.routes.url_helpers
=> Object
1.9.3dev :002 > gallery_page_path
2006 Jun 29
2
HABTM with multiple select list
Hello,
I am very new to ruby and need to create my first HABTM with multiple
select list.
I am having problems saving data in the middle(linking)
table.
1. titles can have multiple categories
2. categories can have multiple titles
Categories, titles and categories_titles tables are created.
----- title_controller.rb--
def new
@title = Title.new
@categories =
2009 Jun 22
5
has_many through , or habtm , using form
i think there ara two ways of relate products and categories ,
basically i want to fix one product(e.g hp dv7....) to some categories
(notebook,17"notebooks...)
i made a table named categorization(incuding category_id,product_id
fields) then in models i write these codes below
class Product < ActiveRecord::Base
has_many :categories, :through => :categorizations
2006 Aug 12
7
Collection assignment to a has_many :through
I''m working on a simple photo gallery in rails, it seems to be a good
project for a newbie.
I have photos and categories, many-to-many association. It worked well
with HABTM. Then I decided that it would be good to be able to change
order of the photos so that thumbnail pages would look less chaotic.
So I created a Layout model which is a join model (or whatever it is
called) that
2010 Sep 08
2
subbing a string vector for another string vector
I have a data frame with two columns:
image pattern
1 http://$IMAGE_ID$ www.url.com/image.jpg
2 $IMAGE_ID$ http://www.blah.com/image.gif
...
I want to replace "$IMAGE_ID$" with the corresponding entry in the pattern
column such that the result would appear as follows:
url
http://www.url.com/image.jpg
2006 Sep 03
7
using polymorphic associations with acts_as_list
This is what I have
class Photo < ActiveRecord::Base
belongs_to :image, :polymorphic => true
acts_as_list :scope => image
end
class Place < ActiveRecord::Base
has_many :photos, :as => :image
end
class Child < ActiveRecord::Base
has_many :photos, :as => :image
end
I want to be able to reorder the images. What I need is for the
position of the photos to be set
2010 Sep 01
0
Error on update_attributes with HABTM relationship
Hope someone can tell me what''s up, because this has me baffled.
I have an Image model, and a Provider model. Both are defined as
"has_and_belongs_to_many" relating to each other. In my image form
partial, I have a bit of AJAX generating the provider_ids array
dynamically from a provider AJAX search on the same page.
So for example, each time I click on a provider name that
2006 May 31
3
instance variable problem
I''m having some trouble with an instance variable being read as nil in
my app. I have an image uploading, that can be added to categories.
The page loads up initially fine, and if I upload an image without
errors everything works fine. I''m working on the validation, but with
the code I have if their are validation errors it renders ''new'' again,
but reads
2006 May 11
4
modelling data to specify user access
Hello, this is my second Rails app, and the first one I did had simple
data mapping. This time I am building a site for a photographer, and
they want to upload photos, and create galleries that only certain
clients can log in and have access to. There will be multiple
galleries, and the access to them will vary depending on how the admin
assigns it to each client. There is also a porftolio
2006 Feb 13
5
Acts_as_taggable pluralize
I am implementing a messaging system, which requires broadcast to group
feature.
Instead of a relatively clunky habtm group structure, I am using tags.
Form a usability standpoint, it would be helpful to avoid redundant
tags. Like, friend vs friends OR client vs. clients.
Is it practical to filter tags, before entry, to avoid duplicate tags
like plural vs. singular?
--
Posted via
2006 Mar 20
1
FileColumn question
Can someone please help me with this.
I have an Images table :-
create table images (
id integer unsigned not null auto_increment primary key,
image varchar(200) not null default ''''
)ENGINE=InnoDB default CHARSET=latin1;
And a car table :-
create table cars (
id integer unsigned not null auto_increment primary key,
user_id integer unsigned not null,
title varchar(100) not
2010 Mar 27
2
Shorter Rails 3 routes
Hi,
I have a small blog application, and I would like to shorten its routes.
Here they are:
Blog::Application.routes.draw do
resources :categories do
resources :articles do
resources :comments
end
end
A rake routes command produce the following lines:
GET
/categories/:category_id/articles/:article_id/comments(.:format)