Displaying 20 results from an estimated 2000 matches similar to: "Need advice on controller / view"
2010 Oct 12
2
STI and :through, not working?
Artist.first.medias returns all medias. Media is an STI. Media can be
video or painting.
How do I return all paintings of an artist? Only paintings, not
videos?
In my Artist model, I tried putting:
has_many :paintings, :through => :medias
In console, I do:
Artist.first.paintings.all
And I get:
ActiveRecord::HasManyThroughSourceAssociationNotFoundError: Could
not find the source
2010 Oct 01
20
Paperclip not executing FFMPEG properly
Im using a customs processor to run ffmpeg on a video to create a
thumbnail.
So far so good. Except when I do:
cmd = "-i #{@file.path} -f flv -s 320x240 ~/Downloads/foobar/q.flv"
success = Paperclip.run(''ffmpeg'', cmd)
Console is reporting:
ffmpeg ''-i /var/folders/uL/uL0bYOOZEZaJH5E+BmDJVE+++TI/-Tmp-/stream,
16824,1.mpeg -f flv -s 320x240
2010 Oct 14
7
undefined method?
I''m trying to learn rails as I go along, and having a bit of trouble.
There is an undefined method cropping that I don''t know why rails
thinks should be there.
Firstly, I''m using rails 3, ruby 1.9.2
I have a controller with an index action This part works fine, but i
am trying to add a comment form to the page that is rendered by that
index action.
Supposing my
2010 Nov 05
2
ActiveRecords queries: .where vs .find
I have a dataset, which contains a day column that I would like to
retrieve results on. Is there any reason why daily_stats.where(''day =
Date(?)'', dte).first returns and empty set,
daily_stats.find(:first, :conditions => [''date(day) = ?'', dte])
returns the correct data and daily_stats.where({:created_at =>
(date.midnight - 1.day)..date.midnight}).first
2010 Feb 11
3
Parameterized ActiveRecord Associations: Any such thing?
Hi list, how are ya?
So, my current project is just begging for the ability to have
parameterized associations in my ActiveRecord classes. Basically I
need something that is a cross between named scopes and standard
associations (has_many specifically).
I''m wondering if such a thing exists or, if not, if anyone else has an
elegant, equivalent solution?
Example:
class Sprocket <
2008 Oct 10
2
Add hash to serialized column
Hey guys,
I''m trying to merge a hash with another using the .merge! function.
class User < ActiveRecord::Base
serialize :preferences
end
This is what I end up with in the console:
>> u = User.find(1)
>> u.preferences.merge!{:test => 1}
SyntaxError: compile error
(irb):32: syntax error, unexpected tASSOC, expecting ''}''
u.preferences.merge!{:test
2010 Sep 08
4
OpenSSL
Hello anyone used OpenSSL before?
Why do we need to pay for expensive SSL certs when there is OpenSSL
which is provided free? Is there a difference?
I''ve got an ecommerce website, and wondering if OpenSSL is enough?
Your thoughts will be appreciated
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this
2010 Oct 18
5
How to create a "like" button
Ive got a like and video model.
On a Video page, Users can click a link ("like") button which will
allow them to like a particular video.
Since my like button/image comes in the form of a link and not an
actual html form. How should this be implemented? Do I need to specify
a ":method => puts" in my link_to tag helper?
What are your thoughts?
--
You received this
2006 May 04
4
form post not working
Hi there,
I have this form code in a view:
<%= start_form_tag :action => "listByArtist", :id => artist.id %>
<p><b>List by Artist:</b>
<select id="artist_id" name="artists[id]">
<%= options_from_collection_for_select(@artists, "id", "name") %>
</select>
<%= submit_tag "List"
2011 Mar 19
5
Routing issue
Hi!
I have two models, artists and songs.
I have this in my route file:
resources :artists, :path => "ackord" do
resources :songs
end
Which gives me urls like this (I''m using https://github.com/norman/friendly_id
to create and manage slugs):
example.com/ackord/artistname/songs/songname-id
Now I want to remove the /songs part to get a url like this:
2010 Oct 08
1
How to access virtual attributes in the model
I''ve got an artist form. In this form I''ve got attributes that do not
exist in the model that the form belongs to. However, I would like to
submit these values for later processing.
My virtual attributes in the form are:
<%= f.label :foobar %>
<%= f.text_field :foobar %>
In the artist model, I created a getter:
def foobar
end
When the form is
2010 Oct 15
1
Help with nested form: User and Artist
Artist is 1:1 with User. User has_one :artist
In my artist model, I have:
belongs_to :user
accepts_nested_attributes_for :user
However, in my artist _form, the name column from the user model does
not display. I am doing:
<% f.fields_for :user do |builder| %>
<p class="fields">
<%= builder.label :name %>
<%= builder.text_field :name %>
2006 Dec 07
2
need to transfer data from old php like db to rails style db
hey all,
I have two tables like that from an old php project:
artists(id,name)
albums(id,artist_id,album_name)
and I need to transfer the data of this database to three tables that
look like this:
artists(id,name)
albums(id,name)
artists_albums(album_id,artist_id)
any idea what''s the fastest query to do this?
thanx in advance
Pat
--~--~---------~--~----~------------~-------~--~----~
2008 Sep 18
8
handling association changes? What's the best practice?
Hello all!
I have a conundrum that I''m _sure_ someone else has already thought of
and solved. How does one best handle the scenario of association
object changes and data integrity?
For example, if I have a standard ecommerce site that sells Products
and people can have Orders and an Order has_many Products... then,
what happens if Product #3 is part of Order #2 but at some point, the
2009 Mar 11
1
NoMethodError for select_tag
Hello there. I am following a tutorial with rails 2.1 and I have come
across a problem where
<%= f.label :artist_id %><br />
<%= f.select_tag(:artist_id, options_for_select([[''choose one'',
'''']] + @artists.collect {|art| [art.name, art.id]}, @album.artist_id))
%> (Old artist info:<%= @album.artist_old%>)
gives
undefined method
2010 Oct 13
3
using pg on snow leopard
I have a macbook running snow leopard. I recently installed postgresql
9.0 on it. I also installed pg with the following command:
sudo env ARCHFLAGS=''-arch x86_64'' gem install pg
The result was fine:
Building native extensions. This could take a while...
Successfully installed pg-0.9.0
1 gem installed
Installing ri documentation for pg-0.9.0...
Installing RDoc documentation
2008 Oct 10
2
Another "I'm I right" question...
I''m pretty sure that there''s a better way to do this:
@roles = Role.find(:all)
@selected_role = Role.find(@user.role_id)
Can someone help me?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2007 Feb 26
24
Ruby/rails port of Cocoon/hibernate
Hi,
I''m currently running an apache/jboss cocoon/flow/hibernate/ajax
paypal (directpayment) project and am looking into the possibility of
porting it across to ruby/rails. For that reason I would like to know
the following:
1. Can I call my java classes or would I be looking at a complete
rewrite in ruby?
2. How effective is ruby in terms of seperation of concerns regarding
design from
2006 May 22
4
use join table in paginate
How come I allways immediately run into difficult stuff when I''m trying
some new programming language? Am I blind for the simplicity of
Ruby/Rail, which a see must be there? Anyway, don''t try and answer this
rhetoric question. I have got another one for you, seemingly difficult.
I''m struggling with a n:m relationship (in a database, that is) and its
join table.
2006 Jan 29
8
Determining width and height of image files
I''m trying to figure out how to determine the width and height of images
that are uploaded through my app. Either from the posted data or the
file I save to disk. I''ve been searching around for info but no luck;
I''m completely at a loss. Any suggestions or pointers would be great.
Project background:
The site is an artists portfolio site. The images are thumbnails