Re: [Rails] Converting an Existing Website: Removing Duplicate Meta Data

2010-10-06 Thread Maksim Gudovsikov
Hi,

you could try putting a canonical tag into your view. Saying google that
/photos is the same content as /photos.html.

http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html

Greets, Max.



Am 06.10.2010 16:49, schrieb Christine Nyb:
> Hi,
> 
> I have searched the forum to see if this has come up before.  If it has
> and I missed it I am sorry.
> 
> I'm fairly new to Ruby on Rails and have converted an existing site.  To
> avoid annoying redirects and disrupting search engine results I updated
> the routes.rb file so that the old file name renders the correct rhtml
> file.  For example, photos.html renders /photos.
> 
> It works but the problem is that Google Webmaster Tools sees duplicate
> meta data and titles for each page. I would really appreciate
> information on how to correct this. I have been trying to figure out how
> to get google to ignore .html files or treat them as duplicate data but
> have had no luck so far.
> 
> Thanks,
> 
> Christine

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Bad experiences with ruby on rails 3.0 :(

2010-10-06 Thread egervari
I just installed it and it seems like everything goes smoothly... but
I'm having one hurdle after another installing a new application. I've
had to get various dlls for sqlite, mysql and msvcrt-ruby18, or things
out-right crashed.

I've had an error where rails though I didn't have rake installed...
but the gem was installed. I had to remove a file called rake.gemspec
and reinstall rake for everything to work.

I don't mean this to sound bad, but for a framework that claims to
"just work", it certainly has it's share of bugs or hurdles. Maybe
it's just because I run windows 7 64-bit. I dunno :(

These seem like platform issues to me, an area that Java really does
have a leg up on. At least when you install java... it works :/

I'll keep playing with it. I hope after these hurdles, everything will
eventually just work.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Gems installation on Windows

2010-10-06 Thread Ashwin Appiah
I'm trying to install some gems on my windows machine. Rails, rake, gem
work completely fine. But when for example I'm trying to install
gravatar_image_tag. It installs completely fine but on the windows
command prompt its not being recognized. When I type in
"gravatar_image_tag -v" I get an error message saying that
gravatar_image_tag is not recognized whereas when I type in "rails -v"
its giving me the right output with 3.0.

I tried setting the path to the ruby lib folder in C: but it still is
not working.

Does it have to do with C: permissions? This is really irking me. Any
help would be great.
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: how to connect to microsoft sql server 6.5

2010-10-06 Thread prinx
Ok, i'll try yours advice, i hope to do it...
I will let you know :-)

Thank's
Prinx

On 6 Ott, 14:51, pepe  wrote:
> Forgot to add database.yml configuration. Here it is:
>
> your_environment_here:
>   adapter:  sqlserver
>   mode:     odbc
>   dsn:      your_dsn_name_here
>   username: your_username_here
>   password: your_password_here
>
> There is no need to use host or port parameter since we're using a
> DSN.
>
> On Oct 5, 8:40 am, pepe  wrote:
>
> > I only know about SQLServer 2005 and 2008, not 6.5. Anyway, here is a
> > list of things I had to do to get a project working with 2005 using
> > Ruby 1.8.6, Rails 2.3.5 and Mongrel as the web server. You might need
> > to skip/change some of the steps. I hope it helps:
>
> > 1.      Install Ruby (1.8.6):http://www.ruby-lang.org/en/downloads/
> > 2.      Install rubygems:
> >   a.    http://rubygems.org/pages/download(zipversion)
> >   b.    Unpack to a directory and cd there
> >   c.    ruby setup.rb
> > 3.      Install rails: gem install rails –v=2.3.5
> > 4.      Install mongrel: gem install mongrel
> > 5.      Install mongrel service: gem install mongrel_service
> > 6.      Install SQL Server adapter: gem install activerecord-sqlserver-
> > adapter
> > 7.      Install ODBC gem: gem install odbc-rails
> > 8.      Install authentication gem: gem install authlogic
> > 9.      Install encryption gem: gem install attr_encrypted
> > 10.     Install SQL Server Management utility (from Microsoft)
> > 11.     Create SQL Server DB
> > 12.     Create login in SQL Server
> > 13.     Create DB user
> > 14.     Create DSN in Windows:
> > a.      Control Panel -> Adminstrative Tasks -> Data Sources (ODBC)
> > b.      Click on System DSN -> Add
> > c.      Select type SQL Server
> >   i.    Name: *Give it a name*
> >   ii.   Description: *Give it a description*
> >   iii.  Server: Server name (*whatever name you can see in the SQL
> > Server Management Utility*)
> >   iv.   Use SQL Authentication
>
> > On Oct 4, 5:11 pm, prinx  wrote:
>
> > > Hi all,
> > > i'm beginner in rails world...i try to connect my rails application on
> > > a db sql server 6.5 without success, ca you help me?
> > > i try odbc driver, jtds e activerecord-sqlserver-adapter but
> > > nothing...
> > > what are the right gems or the right sequence procedure?
>
> > > thx
> > > Prinx

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails 3 - Referencing the URL to determine i f a Nav Item is class=“selected”

2010-10-06 Thread nobosh
The app can have the following URLs:

 /projects/ 
 /projects/3 
 /projects/3/photos 
 /projects/3/photos/312 

I'd like to know how in Rails 3 I can look at the current URL and know
which of the lines above is currently active, so I can add a
class="selected"

Additional exmaple..

If the user's browser is on: /projects

And the Nav looks like

Projects
  - Photos
  - Files

Projects is Active

but if the user's browser is on: /files

Projects is active

and Files is active (they both apply).


Ideas? thanks

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] I need help with a design

2010-10-06 Thread radhames brito
please help!!   T_T

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: How RoR handles multiple sub-websites under one host?

2010-10-06 Thread radhames brito
On Wed, Oct 6, 2010 at 10:24 PM, pepe  wrote:

> Why don't you install Mongrel and run your RoR apps through it instead
> of IIS? I've never used IIS but the stories told about it don't paint
> a pretty picture. Mongrel is very easy to install and you can run it
> as a Windows service with Automatic start.
>
>

@pepe

last time i checked , mongrel is single threaded so you need to run like 5
mongrel instances each with the rails app loaded, and running on a different
port, if you dont do that user response will be queued and the app will look
super slow, also, since each mongrel will run on a different port you are
going to need a load balancer that switches from one mongrel to another and
maps all of them to port 80.

god bless passenger!

step 1)

run command and wait 30 secs

step 2)

copy paste

step 3)

edit server name and app path

step 4)

restart webserver (apache/nginx)

step 5)

fall in love

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: How RoR handles multiple sub-websites under one host?

2010-10-06 Thread pepe
Why don't you install Mongrel and run your RoR apps through it instead
of IIS? I've never used IIS but the stories told about it don't paint
a pretty picture. Mongrel is very easy to install and you can run it
as a Windows service with Automatic start.

On Oct 5, 10:29 pm, crab  wrote:
> Hi Marnen,
>
> > > My question is, how can I start one "ruby server" and use one config
> > > for multiple sub-websites?
>
> > You normally wouldn't want to, if they're completely separate Rails
> > apps.  If they don't share data or anything, they should be independent
> > Rails applications running on separate interpreter instances.
>
> I am working for university and there are nearly a hundred of sub-
> websites under my host.
> Running ruby server instances and maintaining config files of that
> amount may not be feasible for me.
>
> Actually, we are currently using ColdFusion which has a admin console
> to handle the application server settings.
> I want to keep the practice as similar as possible.
>
> > Server modules like Passenger make this sort of thing very easy to set
> > up...but you're using IIS (why?!?), and Passenger doesn't run on IIS.
>
> Oh, yeah!  Phusion Passenger is useful.  I've heard of it.
>
> But (very) unfortunately, our server config is Windows-base, using IIS
> as web server, and database is MS-SQL...
> It seems to be quite a tough job to introduce RoR to my workplace
> under this environment.
> I have to make it!
>
> Cheers,

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: free ruby on rails hosting?

2010-10-06 Thread MarcRic
Hi Tony and others.

Please keep patience. The RoR community is more then that.

Time to time hosting services are questioned on many RoR groups. Here
in Brazil or elsewhere this is a recurrent subject.

It is not exactly free, but may help e few Google searches.

In my blog (http://marcricblog.blogspot.com/), there is a link (in the
very beginning) to a hosting ranking company.

There is a specific RoR session.

I suggest a close look.

--
MarcRic
www.marcric.com
http://marcricblog.blogspot.com/
http://www.traineronrails.com/
http://groups.google.com.br/group/riorubyrails


On Oct 6, 5:29 am, tonypm  wrote:
> > Forums are here for people to ask questions.
>
> > Now you look like a douche every time someone searches for free RoR
> >hosting.
>
> Actually, I would have said that the forums were for people to get
> answers, not much point asking a question if no-one is going to
> provide a useful answer.
>
> I have found most of my questions answered by searching the forum and
> looking at responses to previous questions - so that mostly I have not
> had to ask the question myself.  In fact I learned to use ruby on
> rails that way .
>
> This forum used to excel in a) the quality of responses, depth and
> helpfulness AND b) politeness and patience.
>
> Sadly these things seem to be getting eroded.  It would be nice if we
> could keep to being polite and user friendly and provide responses
> that have useful content.  Remember, if you give a helpful answer, you
> haven't solved just a single user's query, you have provided
> documentation for many others when the search the forum in the
> future.  If you can't resist saying "read the docs" or "it has been
> answered in another post", then at least have the decency to point to
> the post or reference with a proper link - otherwise wouldn't it just
> be better to say nothing.
>
> I have been feeling these things for several weeks now, and my
> disappointment in the rails community has been growing.  This post
> just tipped the balance so I felt I had to make a comment.
>
> with very best intentions
> Tonypm

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Is Java Dead?

2010-10-06 Thread radhames brito
You know what i would like to know the same this about C# in web
development, how is that doing?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] I need help with a design

2010-10-06 Thread radhames brito
I have been working on an app but ran into many problems when i was
applying authentication and authorization.

I want to have the following users with the given abilities.

Admin: full control on the entire system, but apart from login , email
and password it does not require any more attributes

company owner: should be able to created the number of companies the
admin approves, and have full control over all of its companies, i
would like to send an invitation to this user type

user: should have different roles and has couple more fields than the
company owner. The super user roles can only have full control over
its own company. user cant create companies and should belong to a
company and cant create companies. owners or super users should be
able to create them via a crud

client: if approved by the admin a company is clients are allowed to
log in  to the system, they only have read access to their personal
data and an internal email system. Have lots of fields, ca be
affiliated to a company but the admin has access to all clients in the
system. company owners only have access to their companies clients ,
and the users only to the clients that are affiliated to their
company.

the problem comes now, I have 4 models at the moment, i would like
authentication an authorization systems to be common to all of them. I
have 4 abilities with cancan, and 4 resources with devise, but keeping
up with everything was very redundant, i have 4 login page 4 path to
signout, etc. If i unify all users in a single model an manage
everything with fields in the DB im a little confuse on how to handle
the company users relation since companies belong to owners in the
current design but a company has many users and clients.

I have been thinking of a has many through association with resources
called ownership, employ and affiliation
and use boolean fields or a user type field to differentiate each type
of user. I would need a lot of conditional validations of course.
would STI be helpful or would it require 4 of everything anyway? i
want to have one login page and one ability class.

Anyone has a better solution? i would appreciate some comments on
this.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Is Java Dead?

2010-10-06 Thread egervari
I'm just curious if you think Java is dead. If you post a message on
Spring's forums... you not only probably won't get any responses, you
will be lucky to get 1 or 2 views per day. Does that mean it's pretty
much dead, or do lots of people still use it but just don't visit the
forums?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] What is the best way to learn rails 3.0 with no prior rails experience?

2010-10-06 Thread Philip Hallstrom
> What is the best way to learn rails 3.0 with no prior rails or ruby
> experience? I'm just curious about it and want to get started.

Learn Ruby first.  Or at least enough Ruby that you don't think of Rails as 
being magical.

http://humblelittlerubybook.com/ - Free (donations welcome).  I've never read 
it...

http://www.manning.com/black2/ - Excellent.

http://www.manning.com/katz/ - Rails 3.  Not out yet, but seems good so far.

Disclaimer - I like manning's books and have reviewed several.  I'm sure there 
are other good ones as well...  I don't get anything for it, but there you go :)

> Do I start with 3.0 or 2.0?

3.0.


> If one is a very good OO developer and knows Java and Scala really
> well, would it be hard to get by with rails without knowing much ruby?
> (basically learning book at the same time).

Personally I think you'll hit the wall at "above a basic CRUD app".  You'll 
have an advantage over someone who doesn't know any language well, but spending 
a couple of days cruising through some ruby books will certainly be time well 
spent.

-philip

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Small issue with user and artist model

2010-10-06 Thread Christian Fazzini
Hmmm, now that I think about it. Yes, you are right...

On the side. Marnen, would you keep this schema as is, or would you
modify it, in any way? Perhaps, as I was suggesting about having the
User model as an STI? Or even polymorphic? What are your thoughts?

On Oct 7, 4:33 am, Marnen Laibow-Koser  wrote:
> Christian Fazzini wrote:
> > Ok, Ive got the following models:User, Artist and Video
>
> > User is 1:1 with Artist (A user can register to be an artist)
> > Artist is 1:M with Video (An artist can have one or many videos)
>
> > Note that, before any user can register as an artist. He/she must
> > already have an account with the system. i.e. He must be a registered
> > user first. Hence the 1:1 relationship with User and Artist.
>
> > Here is the problem, when an artist tries to upload a video:
>
> >   def create
> >     @video = Video.new(params[:video])
> >     @video.artist = current_user.artist
>
> > -
>
> > For this particular user:
> > In the User model, he has id => 29
> > In the Artist model, he has id => 1, user_id => 29 (user_id being the
> > foreign key)
>
> > This means, when the video record is saved to the db. It is saved as:
> > id => 1, artist_id => 1 (instead of 29), title => 'foobar', etc
>
> > How can such be fixed?
>
> There's nothing to fix.  artist_id is giving the ID of the artist
> record, not the user record.  This is exactly what you've asked Rails to
> do.
>
> > Should I remodel my schema? I was thinking of
> > just having one User model and have this as an STI. Member (Registered
> > users) and Artist models would inherit from the User model.
>
> That might work, or just have a role field in your User model, and only
> role "artist" can upload videos.
>
> Or get rid of the distinction altogether, and do something like
> class User
>   def artist?
>     self.videos.size > 0
>   end
> end
>
>
>
> > What is a better approach to fixing this?
>
> I don't think it's broken.
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Script acting differently inside of rake task

2010-10-06 Thread Paul
SOLVED:

I needed:

gem 'daemons'

in my Gemfile.

When I ran it from the command line, it doesn't go through bundler,
but evidently, even though I'm supposedly just spawning a separate
process, it magically is.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: What is the best way to learn rails 3.0 with no prior rails experience?

2010-10-06 Thread egervari
Yes, I do test-first for the last 8 or so years. I am a little
familiar with RSpec's design because ScalaTest has parts that are
blatant ripoff of RSpec ;) I love ScalaTest, so I will probably like
RSpec.

What do you mean by factories? I know of the factory pattern, but what
do you mean specifically?

Also, is it easy to disable the testing framework that is shipped with
rails and get it to use RSpec?

On Oct 6, 6:31 pm, Marnen Laibow-Koser  wrote:
> David Kahn wrote:
> > I would recommend the book Agile Web Development with Rails. I know
> > there is
> > a new version for Rails 3. I think if you do the practical tutorial
> > part,
> > which if I remember is only maybe 100-200pages, you should just jump in.
> > I
> > came from asp.net and this worked for me. Then soon you will want to
> > learn
> > more ruby but seriously, I think you can become dangerous pretty quick
> > with
> > this book if you learn well doing self directed stuff.
>
> Just do all development test-first (I recommend RSpec and Cucumber;
> avoid Rails' fixtures entirely and go straight to factories).  And of
> course, use version control.
>
>
>
> > David
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Script acting differently inside of rake task

2010-10-06 Thread Paul
> Check the environment used by `` - could it be picking up a different
> $PATH  (and thus a different ruby install) ?
>
> Fred

Well, that's odd, too. If I put:

puts `set`

in my rake file, it gives me the error:

/usr/local/lib/ruby/gems/1.8/gems/railties-3.0.0/lib/rails/application.rb:103:
command not found: set

Which doesn't make sense to me at all.

Anyway, `ruby -v` gives the same version from the command line as from
the rake file, and this computer only has one version of ruby anyway,
so I figured it would.

Any other ideas? Or any workarounds?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: What is the best way to learn rails 3.0 with no prior rails experience?

2010-10-06 Thread Marnen Laibow-Koser
David Kahn wrote:
> I would recommend the book Agile Web Development with Rails. I know 
> there is
> a new version for Rails 3. I think if you do the practical tutorial 
> part,
> which if I remember is only maybe 100-200pages, you should just jump in. 
> I
> came from asp.net and this worked for me. Then soon you will want to 
> learn
> more ruby but seriously, I think you can become dangerous pretty quick 
> with
> this book if you learn well doing self directed stuff.

Just do all development test-first (I recommend RSpec and Cucumber; 
avoid Rails' fixtures entirely and go straight to factories).  And of 
course, use version control.

> 
> David

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Drop-down menu from a belongs_to association

2010-10-06 Thread Marnen Laibow-Koser
Marnen Laibow-Koser wrote:
[...]
>> so I add an "f." to select, like this
>> 
>>   
>> <%= f.label :client_id %>
>> <%= f.select ("post", "client_id", Client.all.collect {|client|
>> [client.name,client.id]}, :prompt => "Select client" ) %>
>>   
> 
> That is the correct syntax for the f.select call,

Actually, it isn't.  When you're using form helpers inside a FormBuilder 
(as in this case), remove the first argument (in this case "post"). 
Since you're not doing that, you're passing the arguments in funny 
places, and FormOptionsHelper is getting confused.

Also, you don't need the parentheses.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Drop-down menu from a belongs_to association

2010-10-06 Thread Marnen Laibow-Koser
Leonel *-* wrote:
> I'm trying to enter a client (from clients table (model), client_id)
> into a form for appointments. The client_id is supposed to be entered
> into the appointments table.
> 
> If I use
>   
> <%= f.label :client_id %>
> <%= select ("post", "client_id", Client.all.collect {|client|
> [client.name,client.id]}, :prompt => "Select client" ) %>
>   
> 
> I get a drop down menu with clients,

...but never, ever do database access in the view!  That belongs in the 
controller.

> but when I submit it, it tells me
> that it's blank. so I add an "f." to select, like this
> 
>   
> <%= f.label :client_id %>
> <%= f.select ("post", "client_id", Client.all.collect {|client|
> [client.name,client.id]}, :prompt => "Select client" ) %>
>   

That is the correct syntax for the f.select call, but may not be 
supplying the correct values.  What does the generated HTML from that 
select look like?  Or do you get the error before it even gets to that 
point?

This is a case where collection_select will make your life easier.

Best,
--
Marnen Laibow-Koser
http;//www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Use .ogv videos with Rails

2010-10-06 Thread CiriusMex
The .ogv file from other server is played in html5, the same file
won't be played on the server of the application still in html5. I
think there's a problem of access and that's why I though about the
mime types.

On 6 oct, 16:12, Marnen Laibow-Koser  wrote:
> Please quote when replying.
>
> CiriusMex wrote:
> > Hello Marnen,
>
> > Yes, I made a test using this video link
> >http://v2v.cc/~j/theora_testsuite/320x240.ogg
> > and Firefox displayed it just fine,
>
> With HTML 5 or Flash?
>
> > then uploading the same file to
> > the server where we host the site and updating the url, the video
> > won't be displayed.
>
> With HTML 5 or Flash?
>
> > The problem only occurs with html5 player (FF 3.6.10), I use a flash
> > fallback method with a mp4 file and it works great.
>
> To Firefox, the Flash method is simply a Flash movie that it can hand
> off to the Flash plugin, and therefore is not relevant to the current
> issue -- it does not appear to the browser as an .ogv file.
>
> So...can Firefox play .ogv videos when served from other sites *as .ogv,
> not Flash*?
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Drop-down menu from a belongs_to association

2010-10-06 Thread Leonel *-*
I'm trying to enter a client (from clients table (model), client_id)
into a form for appointments. The client_id is supposed to be entered
into the appointments table.

If I use
  
<%= f.label :client_id %>
<%= select ("post", "client_id", Client.all.collect {|client|
[client.name,client.id]}, :prompt => "Select client" ) %>
  

I get a drop down menu with clients, but when I submit it, it tells me
that it's blank. so I add an "f." to select, like this

  
<%= f.label :client_id %>
<%= f.select ("post", "client_id", Client.all.collect {|client|
[client.name,client.id]}, :prompt => "Select client" ) %>
  

but when i submit the form it gives me this error
undefined method `merge' for [["Angelina Jolie", 1], ["Barney Stenson",
3], ["Ted Mosby", 2]]:Array

Whyyy?
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] What is the best way to learn rails 3.0 with no prior rails experience?

2010-10-06 Thread David Kahn
I would recommend the book Agile Web Development with Rails. I know there is
a new version for Rails 3. I think if you do the practical tutorial part,
which if I remember is only maybe 100-200pages, you should just jump in. I
came from asp.net and this worked for me. Then soon you will want to learn
more ruby but seriously, I think you can become dangerous pretty quick with
this book if you learn well doing self directed stuff.

David

On Wed, Oct 6, 2010 at 4:35 PM, egervari  wrote:

> What is the best way to learn rails 3.0 with no prior rails or ruby
> experience? I'm just curious about it and want to get started.
>
> Do I start with 3.0 or 2.0?
>
> If one is a very good OO developer and knows Java and Scala really
> well, would it be hard to get by with rails without knowing much ruby?
> (basically learning book at the same time).
>
> Any good books that do a fantastic and thorough job at not really
> explaining how an MVC works but how everything works in rails
> specifically? Something that doesn't just look at "the most basic
> case", but really gets in there above a basic CRUD app.
>
> I was flipping through a book about rails 2.0 at Chapters and the
> first 20 pages kept giving a sales pitch about how easy rails is, and
> yadda yadda. It tended to rip on java a lot... but since I know Java
> really well, I thought the author didn't know what he was talking
> about. His comparisons and examples of Java were biased... either
> comparing it to the language itself or to frameworks that I wouldn't
> even consider using because they suck (struts, etc.). I think his goal
> was to make it look worse than it really was. Spring 3.0, while not
> ideal, isn't nearly as bad as the author was letting on... and I guess
> I lost confidence in the author because he didn't even bother to
> mention Spring.
>
> Anyway, any advice to some lean yet informative and intelligent books
> would be helpful. I thought the Scala book written by Martin and crew
> was fantastic, so if a book exists at that caliber, I'm very open to
> reading it.
>
> Thanks
>
> --
> 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 rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: What is the best way to learn rails 3.0 with no prior rails experience?

2010-10-06 Thread Marnen Laibow-Koser
egervari wrote:
> What is the best way to learn rails 3.0 with no prior rails or ruby
> experience? I'm just curious about it and want to get started.
> 
> Do I start with 3.0 or 2.0?

If I were starting today, I'd probably learn Rails 3.

> 
> If one is a very good OO developer and knows Java and Scala really
> well, would it be hard to get by with rails without knowing much ruby?
> (basically learning book at the same time).

Make sure to learn enough Ruby that you can understand what's going on.

> 
> Any good books that do a fantastic and thorough job at not really
> explaining how an MVC works but how everything works in rails
> specifically? Something that doesn't just look at "the most basic
> case", but really gets in there above a basic CRUD app.

You don't need that yet, I think.  Learn the basics of the framework 
first.

> 
> I was flipping through a book about rails 2.0 at Chapters and the
> first 20 pages kept giving a sales pitch about how easy rails is, and
> yadda yadda. It tended to rip on java a lot... but since I know Java
> really well, I thought the author didn't know what he was talking
> about. His comparisons and examples of Java were biased... either
> comparing it to the language itself or to frameworks that I wouldn't
> even consider using because they suck (struts, etc.). I think his goal
> was to make it look worse than it really was. 

I do know Java fairly well.  I also know Ruby.  Java is so inflexible by 
comparison that I'd be quite happy never to use it again (except in the 
context of something like JRuby).

The big advantage of the Rails framework (that no one talks about) 
really is the Ruby language.  This is why no PHP or Java framework can 
compare to it IMHO.

> Spring 3.0, while not
> ideal, isn't nearly as bad as the author was letting on... and I guess
> I lost confidence in the author because he didn't even bother to
> mention Spring.

Which?  He said it was bad or he didn't mention it?  You can't have it 
both ways.

> 
> Anyway, any advice to some lean yet informative and intelligent books
> would be helpful. I thought the Scala book written by Martin and crew
> was fantastic, so if a book exists at that caliber, I'm very open to
> reading it.

Agile Web Development with Rails?  (Never read it, since I don't do 
paper books for programming most of the time, but it is the "canonical" 
book.)

> 
> Thanks

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] What is the best way to learn rails 3.0 with no prior rails experience?

2010-10-06 Thread egervari
What is the best way to learn rails 3.0 with no prior rails or ruby
experience? I'm just curious about it and want to get started.

Do I start with 3.0 or 2.0?

If one is a very good OO developer and knows Java and Scala really
well, would it be hard to get by with rails without knowing much ruby?
(basically learning book at the same time).

Any good books that do a fantastic and thorough job at not really
explaining how an MVC works but how everything works in rails
specifically? Something that doesn't just look at "the most basic
case", but really gets in there above a basic CRUD app.

I was flipping through a book about rails 2.0 at Chapters and the
first 20 pages kept giving a sales pitch about how easy rails is, and
yadda yadda. It tended to rip on java a lot... but since I know Java
really well, I thought the author didn't know what he was talking
about. His comparisons and examples of Java were biased... either
comparing it to the language itself or to frameworks that I wouldn't
even consider using because they suck (struts, etc.). I think his goal
was to make it look worse than it really was. Spring 3.0, while not
ideal, isn't nearly as bad as the author was letting on... and I guess
I lost confidence in the author because he didn't even bother to
mention Spring.

Anyway, any advice to some lean yet informative and intelligent books
would be helpful. I thought the Scala book written by Martin and crew
was fantastic, so if a book exists at that caliber, I'm very open to
reading it.

Thanks

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Problem writing to database using form_for

2010-10-06 Thread radhames brito
> I think Jim is querying whether one can access the session variable
> from within the model, and even if one can, whether one should.
>
>
Oh i see, well i will test if is available in the model and if possible ill
see if there a problem with it.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Problem writing to database using form_for

2010-10-06 Thread Colin Law
On 6 October 2010 22:07, radhames brito  wrote:
>
>
> On Tue, Oct 5, 2010 at 5:43 PM, Jim Burgess  wrote:
>>
>> Radhames Brito wrote:
>> > save it in the session hash on validation
>>
>> Hi,
>>
>> Thanks for the reply.
>> Did I understand you correctly, that you are suggesting setting a
>> session variable in the model (where my validation is taking place)
>> which I can then pass to the controller?
>>
>> I didn't know that that was possible.
>> Any hacks around this seem to be regarded as bad practice:
>> http://www.ruby-forum.com/topic/160769
>>
>> If I have misunderstood you please let me know.
>>
>
> are you use to using the flash? like flash[:notice]? well the session[:]
> object is just like it, it exits across request and it exist in the context
> of th user, that is, each user has its on session object. The difference is
> that what you store in the flash is deleted after one request but what you
> store in session is there untill the session is reset or you delete the
> object. Is often used in ecomerce app to store the cart like this
> session[:cart], and you can store anything in it. In fact storing options
> can be set to make it store in the DB.

I think Jim is querying whether one can access the session variable
from within the model, and even if one can, whether one should.

Colin

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Use .ogv videos with Rails

2010-10-06 Thread Marnen Laibow-Koser
Please quote when replying.

CiriusMex wrote:
> Hello Marnen,
> 
> Yes, I made a test using this video link 
> http://v2v.cc/~j/theora_testsuite/320x240.ogg
> and Firefox displayed it just fine,

With HTML 5 or Flash?

> then uploading the same file to
> the server where we host the site and updating the url, the video
> won't be displayed.

With HTML 5 or Flash?

> The problem only occurs with html5 player (FF 3.6.10), I use a flash
> fallback method with a mp4 file and it works great.

To Firefox, the Flash method is simply a Flash movie that it can hand 
off to the Flash plugin, and therefore is not relevant to the current 
issue -- it does not appear to the browser as an .ogv file.

So...can Firefox play .ogv videos when served from other sites *as .ogv, 
not Flash*?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Problem writing to database using form_for

2010-10-06 Thread radhames brito
On Tue, Oct 5, 2010 at 5:43 PM, Jim Burgess  wrote:

> Radhames Brito wrote:
> > save it in the session hash on validation
>
> Hi,
>
> Thanks for the reply.
> Did I understand you correctly, that you are suggesting setting a
> session variable in the model (where my validation is taking place)
> which I can then pass to the controller?
>
> I didn't know that that was possible.
> Any hacks around this seem to be regarded as bad practice:
> http://www.ruby-forum.com/topic/160769
>
> If I have misunderstood you please let me know.
>
>
are you use to using the flash? like flash[:notice]? well the session[:]
object is just like it, it exits across request and it exist in the context
of th user, that is, each user has its on session object. The difference is
that what you store in the flash is deleted after one request but what you
store in session is there untill the session is reset or you delete the
object. Is often used in ecomerce app to store the cart like this
session[:cart], and you can store anything in it. In fact storing options
can be set to make it store in the DB.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Use .ogv videos with Rails

2010-10-06 Thread CiriusMex
Hello Marnen,

Yes, I made a test using this video link 
http://v2v.cc/~j/theora_testsuite/320x240.ogg
and Firefox displayed it just fine, then uploading the same file to
the server where we host the site and updating the url, the video
won't be displayed.
The problem only occurs with html5 player (FF 3.6.10), I use a flash
fallback method with a mp4 file and it works great.

On 6 oct, 15:14, Marnen Laibow-Koser  wrote:
> Is ff (Firefox?) displaying ogv videos from other sites correctly?
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
> --
> Posted viahttp://www.ruby-forum.com/.- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Rails 3, How do I set an :onload for a link_to :remote?

2010-10-06 Thread radhames brito
i have an example app that uses unobstrusive javascript but is running
jquery, take a look and ask any questions you want.

http://github.com/rbritom/Simple_polymorphic_nested_comments

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Passing a hash from the model to the view

2010-10-06 Thread Leonel *-*
> Also guessing that you probably need to have that hash available to both 
> the edit and new pages so you will probably need to set @durations using 
> a before_filter:
> 
> before_filter load_durations, :only => [ :new, :edit ]
> 
> private
> def load_durations
> @durations = { "30 minutes" => "30",
>"1 hour" => "60",
>"1 hour 30 minutes" => "90",
>"2 hours" => "120" }
> end

The above was very useful too, helped me adhere to the DRY principles. I 
feel like a toddler, I used to just code with PHP whatever my 
imagination demanded, now I have to stop every line of code to make sure 
I'm doing everything correctly lol

Thanks
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: find_by_id with multiple ids?

2010-10-06 Thread Marnen Laibow-Koser
Rob Biedenharn wrote:
> On Oct 6, 2010, at 3:34 PM, Jonathan Gill wrote:
>> or possibly
>>
>> people.find_by_name(:all, :conditions => {"name =?", "john"} )
>>
>> Ive no idea if this can be done, or if it can, how to do it.
>>
>> Can someone clue me in?
>>
>> Many thanks
>>
>> Jonathan
> 
> If you want a dynamic finder on name that returns any number of Person
> records, then you simply want:
> 
> Person.find_all_by_name(['john', 'bob', 'mike', 'fred', 'will'])

I wasn't absolutely sure if the find_by_* syntax would also take an 
array.  Good to know!

> 
> -Rob
> 
> Rob Biedenharn

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] find_by_id with multiple ids?

2010-10-06 Thread Rob Biedenharn

On Oct 6, 2010, at 3:34 PM, Jonathan Gill wrote:

Hi all

Not really sure how to put the subject as I know what I want to do,
but really not sure how (or if) I can do it.

What I really want to do is this ;

people.find_by_name(:all,  :conditions => {"name = ?", "john", "bob",
"mike", "fred","will"} )

or possibly

people.find_by_name(:all, :conditions => {"name =?", "john"} )

Ive no idea if this can be done, or if it can, how to do it.

Can someone clue me in?

Many thanks

Jonathan


If you want a dynamic finder on name that returns any number of Person  
records, then you simply want:


Person.find_all_by_name(['john', 'bob', 'mike', 'fred', 'will'])

-Rob

Rob Biedenharn  
r...@agileconsultingllc.com http://AgileConsultingLLC.com/
r...@gaslightsoftware.com   http://GaslightSoftware.com/

--
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Small issue with user and artist model

2010-10-06 Thread Marnen Laibow-Koser
Christian Fazzini wrote:
> Ok, Ive got the following models:User, Artist and Video
> 
> User is 1:1 with Artist (A user can register to be an artist)
> Artist is 1:M with Video (An artist can have one or many videos)
> 
> Note that, before any user can register as an artist. He/she must
> already have an account with the system. i.e. He must be a registered
> user first. Hence the 1:1 relationship with User and Artist.
> 
> Here is the problem, when an artist tries to upload a video:
> 
>   def create
> @video = Video.new(params[:video])
> @video.artist = current_user.artist
> 
> -
> 
> For this particular user:
> In the User model, he has id => 29
> In the Artist model, he has id => 1, user_id => 29 (user_id being the
> foreign key)
> 
> This means, when the video record is saved to the db. It is saved as:
> id => 1, artist_id => 1 (instead of 29), title => 'foobar', etc
> 
> How can such be fixed?

There's nothing to fix.  artist_id is giving the ID of the artist 
record, not the user record.  This is exactly what you've asked Rails to 
do.

> Should I remodel my schema? I was thinking of
> just having one User model and have this as an STI. Member (Registered
> users) and Artist models would inherit from the User model.

That might work, or just have a role field in your User model, and only 
role "artist" can upload videos.

Or get rid of the distinction altogether, and do something like
class User
  def artist?
self.videos.size > 0
  end
end

> 
> What is a better approach to fixing this?

I don't think it's broken.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: find_by_id with multiple ids?

2010-10-06 Thread Marnen Laibow-Koser
Walter Davis wrote:
> Sorry, I did. Please look at my message in a mail application. Google
> hides the quote when showing threaded messages.

Then please don't top-post -- quote like this so it's clear what you're 
replying to.

> 
> Walter

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Use .ogv videos with Rails

2010-10-06 Thread Marnen Laibow-Koser
CiriusMex wrote:
> Hello, I'm trying to read .ogv files in my rails application and have
> a problem with ff, it won't load the video but will show a big X
> instead. After googling for a while I found out the mime types can be
> a problem with FF and add the following lines into my /config/
> initializers/mime_types.rb file according to what I red in this site
> http://9elements.com/io/?p=306:
> 
> Rack::Mime::MIME_TYPES.merge!({
>   ".ogv"   => "video/ogg",
>   ".webm"   => "video/webm",
>   ".mp4"   => "video/mp4"
> })
> 
> But still no changes. I'm using rails 2.3.5 in development mode.
> 
> Any idea?

Is ff (Firefox?) displaying ogv videos from other sites correctly?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: find_by_id with multiple ids?

2010-10-06 Thread Jonathan Gill
Hi Marnen


>
> :conditions => {:name => ['the', 'array', 'goes', 'here']}
>

Worked perfectly!  Many thanks for that!

Cheers

Jonathan

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Script acting differently inside of rake task

2010-10-06 Thread Frederick Cheung


On Oct 6, 7:51 pm, Paul  wrote:

> So, the require for rubygems must have succeeded, since it failed on
> the require for daemons.
>
> Why does it work from the command line, but not from the rake task?
>
Check the environment used by `` - could it be picking up a different
$PATH  (and thus a different ruby install) ?

Fred
> Thanks,

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Small issue with user and artist model

2010-10-06 Thread Christian Fazzini
Ok, Ive got the following models:User, Artist and Video

User is 1:1 with Artist (A user can register to be an artist)
Artist is 1:M with Video (An artist can have one or many videos)

Note that, before any user can register as an artist. He/she must
already have an account with the system. i.e. He must be a registered
user first. Hence the 1:1 relationship with User and Artist.

Here is the problem, when an artist tries to upload a video:

  def create
@video = Video.new(params[:video])
@video.artist = current_user.artist

-

For this particular user:
In the User model, he has id => 29
In the Artist model, he has id => 1, user_id => 29 (user_id being the
foreign key)

This means, when the video record is saved to the db. It is saved as:
id => 1, artist_id => 1 (instead of 29), title => 'foobar', etc

How can such be fixed? Should I remodel my schema? I was thinking of
just having one User model and have this as an STI. Member (Registered
users) and Artist models would inherit from the User model.

What is a better approach to fixing this?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: find_by_id with multiple ids?

2010-10-06 Thread Walter Lee Davis
Sorry, I did. Please look at my message in a mail application. Google  
hides the quote when showing threaded messages.


Walter

On Oct 6, 2010, at 3:50 PM, Marnen Laibow-Koser wrote:


Please quote when replying.

Walter Davis wrote:

The raw SQL way to say this would be "name
IN('john','bob','mike','fred','will')" but I'm not sure how to say
that in the Rails finder format.

Walter


:conditions => {:name => ['the', 'array', 'goes', 'here']}

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails- 
t...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com 
.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en 
.




--
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: find_by_id with multiple ids?

2010-10-06 Thread Jonathan Gill
Thanks for that Walter.

Its getting me a little closer, I'll dig at it and hope I can get it
to play nice. I think find_by_sql is my friend here.

Many thanks

Jonathan

On Oct 6, 8:40 pm, Walter Lee Davis  wrote:
> The raw SQL way to say this would be "name  
> IN('john','bob','mike','fred','will')" but I'm not sure how to say  
> that in the Rails finder format.
>
> Walter
>
> On Oct 6, 2010, at 3:34 PM, Jonathan Gill wrote:
>
> > Hi all
>
> > Not really sure how to put the subject as I know what I want to do,
> > but really not sure how (or if) I can do it.
>
> > What I really want to do is this ;
>
> > people.find_by_name(:all,  :conditions => {"name = ?", "john", "bob",
> > "mike", "fred","will"} )
>
> > or possibly
>
> > people.find_by_name(:all, :conditions => {"name =?", "john"} )
>
> > Ive no idea if this can be done, or if it can, how to do it.
>
> > Can someone clue me in?
>
> > Many thanks
>
> > Jonathan
>
> > --
> > 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 rubyonrails-
> > t...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > rubyonrails-talk+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group 
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en
> > .

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Use .ogv videos with Rails

2010-10-06 Thread CiriusMex
Hello, I'm trying to read .ogv files in my rails application and have
a problem with ff, it won't load the video but will show a big X
instead. After googling for a while I found out the mime types can be
a problem with FF and add the following lines into my /config/
initializers/mime_types.rb file according to what I red in this site
http://9elements.com/io/?p=306:

Rack::Mime::MIME_TYPES.merge!({
  ".ogv" => "video/ogg",
  ".webm"=> "video/webm",
  ".mp4" => "video/mp4"
})

But still no changes. I'm using rails 2.3.5 in development mode.

Any idea?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: find_by_id with multiple ids?

2010-10-06 Thread Marnen Laibow-Koser
Please quote when replying.

Walter Davis wrote:
> The raw SQL way to say this would be "name
> IN('john','bob','mike','fred','will')" but I'm not sure how to say
> that in the Rails finder format.
> 
> Walter

:conditions => {:name => ['the', 'array', 'goes', 'here']}

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] freelancing oppurtunity?

2010-10-06 Thread Gerő Zoltán
Hi all,
we are a little internatioal team, looking for freelancig oppurtunity. Does
anyone have idea where to start? Is there any freelancer site especially for
Ruby and Ruby on Rails developers?
Thanks,
gezope

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] find_by_id with multiple ids?

2010-10-06 Thread Walter Lee Davis
The raw SQL way to say this would be "name  
IN('john','bob','mike','fred','will')" but I'm not sure how to say  
that in the Rails finder format.


Walter

On Oct 6, 2010, at 3:34 PM, Jonathan Gill wrote:


Hi all

Not really sure how to put the subject as I know what I want to do,
but really not sure how (or if) I can do it.

What I really want to do is this ;

people.find_by_name(:all,  :conditions => {"name = ?", "john", "bob",
"mike", "fred","will"} )

or possibly

people.find_by_name(:all, :conditions => {"name =?", "john"} )

Ive no idea if this can be done, or if it can, how to do it.

Can someone clue me in?

Many thanks

Jonathan

--
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 rubyonrails- 
t...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com 
.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en 
.




--
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: reflect_on_association method

2010-10-06 Thread Bojan Mihelac
On Oct 6, 9:17 pm, Marnen Laibow-Koser  wrote:
> Bojan Mihelac wrote:
> > Hi all, I am having trouble trying to use reflect_on_association
> > method with given the simplified model:
>
> > class Order < ActiveRecord::Base
> >   belongs_to :contractor, :class_name => "BusinessUnit"
> > end
>
> > I expected the reflect_on_association method to return
> > associated_foreign_key "contractor_id" but it returns
> > "business_unit_id":
>
> > ruby-1.9.2-p0 >
> > Order.reflect_on_association(:contractor).association_foreign_key
> >  => "business_unit_id"
>
> > do I miss something?
>
> What version of Rails are you using?  At least in the 2.2.2 docs I'm
> looking at right now, :association_foreign_key isn't a valid option for
> belongs_to (it's only for habtm), so I'm not surprised that you're
> getting strange results.  Try foreign_key.
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
>
> --
> Posted viahttp://www.ruby-forum.com/.

I found it, should use primary_key_name:

ruby-1.9.2-p0 >
Order.reflect_on_association(:contractor).primary_key_name
 => "contractor_id"

I thought at first that I would get it with foreign_key but it that
method doesnt exists in
ActiveRecord::Reflection::AssociationReflection

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] find_by_id with multiple ids?

2010-10-06 Thread Jonathan Gill
Hi all

Not really sure how to put the subject as I know what I want to do,
but really not sure how (or if) I can do it.

What I really want to do is this ;

people.find_by_name(:all,  :conditions => {"name = ?", "john", "bob",
"mike", "fred","will"} )

or possibly

people.find_by_name(:all, :conditions => {"name =?", "john"} )

Ive no idea if this can be done, or if it can, how to do it.

Can someone clue me in?

Many thanks

Jonathan

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: reflect_on_association method

2010-10-06 Thread Marnen Laibow-Koser
Bojan Mihelac wrote:
> Hi all, I am having trouble trying to use reflect_on_association
> method with given the simplified model:
> 
> class Order < ActiveRecord::Base
>   belongs_to :contractor, :class_name => "BusinessUnit"
> end
> 
> I expected the reflect_on_association method to return
> associated_foreign_key "contractor_id" but it returns
> "business_unit_id":
> 
> ruby-1.9.2-p0 >
> Order.reflect_on_association(:contractor).association_foreign_key
>  => "business_unit_id"
> 
> do I miss something?

What version of Rails are you using?  At least in the 2.2.2 docs I'm 
looking at right now, :association_foreign_key isn't a valid option for 
belongs_to (it's only for habtm), so I'm not surprised that you're 
getting strange results.  Try foreign_key.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] reflect_on_association method

2010-10-06 Thread Bojan Mihelac
Hi all, I am having trouble trying to use reflect_on_association
method with given the simplified model:

class Order < ActiveRecord::Base
  belongs_to :contractor, :class_name => "BusinessUnit"
end

I expected the reflect_on_association method to return
associated_foreign_key "contractor_id" but it returns
"business_unit_id":

ruby-1.9.2-p0 >
Order.reflect_on_association(:contractor).association_foreign_key
 => "business_unit_id"

do I miss something?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread Marnen Laibow-Koser
jrq wrote:
> On Oct 6, 2:29�pm, Michael Schuerig  wrote:
>> try:
> I've been looking at that.  I'm not sure how that gets around the
> complex queries, unless MySQL supports Materialized Views, which I
> don't think it does (and they're are not a great solution).  Or are
> you assuming that the caching will get around this problem, once it's
> built the first time?

No, views probably won't help performance, just query construction, 
though I don't know enough about how they're implemented to be sure.

PostgreSQL handles views much better than MySQL, IIRC, and is generally 
a better database.  Switch if you can.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Script acting differently inside of rake task

2010-10-06 Thread Paul
I've created a rake task that does various things, one of which is
calling a script. When I call that script from my Rails.root folder,
it works, but it doesn't work inside my rake task. [This is rails 3]

That is, the following line works from bash:

lib/daemons/mailer_ctl start

However, inside my rake task, this line does not work:

puts `lib/daemons/mailer_ctl start`

The error message is:

lib/daemons/mailer_ctl:3:in `require': no such file to load -- daemons
(LoadError)
from lib/daemons/mailer_ctl:3

So, it can't be a problem with the current working directory, because
it found the file to execute.

The daemon is very typical. The first few lines are:

#!/usr/bin/env ruby
require 'rubygems'
require "daemons"
require 'yaml'
require 'erb'

So, the require for rubygems must have succeeded, since it failed on
the require for daemons.

Why does it work from the command line, but not from the rake task?

Thanks,

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread jrq


On Oct 6, 2:29 pm, Michael Schuerig  wrote:
> On Wednesday 06 October 2010, jrq wrote:
>
> > Yes, I'm currently intending to "munge" the unorganized fields into a
> > string, and deal with the parsing/processing at another stage.  yes,
> > it's inefficient, but it's a relatively small amount of processing,
> > and hopefully it will get me to where I need to be within a short
> > amount of time, which is a factor in this situation.
>
> Have you considered using database views? I have never been in this
> situation, so take my suggestions with a grain of salt. Here's what I'd
> try:

I've been looking at that.  I'm not sure how that gets around the
complex queries, unless MySQL supports Materialized Views, which I
don't think it does (and they're are not a great solution).  Or are
you assuming that the caching will get around this problem, once it's
built the first time?

>
> Use database views to map the EAV (non-)schema to sane relational
> schema.
>
> You didn't say if you need to insert into that database. If you do, see
> if MySQL supports updatable views. If it does, give them a try,
> otherwise handle inserts yourself.

I don't need to do any inserts, so that should not be an issue.

>
> If none of this works, consider not using ActiveRecord at all, but
> rather something like sequel is a better fithttp://sequel.rubyforge.org/
>
> Michael
>
> --
> Michael Schuerig
> mailto:mich...@schuerig.dehttp://www.schuerig.de/michael/

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails 3, How do I set an :onload for a link_to :remote?

2010-10-06 Thread Jim
Can anybody provide code/samples/details on how to do this?


On Oct 3, 3:07 pm, Jim  wrote:
> I'm using Prototype.  I mainly want to use the equivalent of :onload
> to show a processing graphic, and :condition to check the value in an
> input field to see if a request should be sent off to the server.
>
> On Oct 3, 1:42 pm, radhames brito  wrote:
>
> > On Sun, Oct 3, 2010 at 1:37 PM, Jim  wrote:
> > > Can you tell me exactly how I would go about doing this?  Code sample
> > > perhaps.  Or any resources that have that information?
>
> > > I already know about the changes to remove the legacy link_to_remote
> > > and other remote helpers, but I haven't found any resources that tell
> > > me more details on how to fully use the replacement.  It's like
> > > upgrading getting a new electric car, but not knowing how to use the
> > > headlights..
>
> > > The main features that I'd like to figure out how to do again
> > > are :onload and :condition.
>
> > The reason you dont find much info is because this now falls in the realm of
> > javascript and has almost nothing to do with rails.
> > Is like looking for info on how to style something or how to build a sql
> > query, is no longer a rails issue. But anyway, i sure can help you but first
> > i need to know what library you are using, go to /public/javascripts folder
> > and tell me if there is a prototype.js or a jquery.js there.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread Marnen Laibow-Koser
Michael Schuerig wrote:
> On Wednesday 06 October 2010, jrq wrote:
>> Yes, I'm currently intending to "munge" the unorganized fields into a
>> string, and deal with the parsing/processing at another stage.  yes,
>> it's inefficient, but it's a relatively small amount of processing,
>> and hopefully it will get me to where I need to be within a short
>> amount of time, which is a factor in this situation.
> 
> Have you considered using database views? I have never been in this
> situation, so take my suggestions with a grain of salt. Here's what I'd
> try:
> 
> Use database views to map the EAV (non-)schema to sane relational
> schema.

Oh, goodness, I forgot to suggest that.  Thanks for the reminder. 
rails_sql_views helps with managing those.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Error on running unity test: "no such file to load -- 'active_record/version'"

2010-10-06 Thread Fabrício Dias
FIXED!

I've moved the statement to a line right after the boot.rb requirement
and now I'm able to run my tests now with no problems.

Thanks, Fred!


On Oct 6, 1:18 pm, Frederick Cheung 
wrote:
> On Oct 6, 1:32 pm, Fabrício Dias  wrote:
>
> > Here it goes, Fred:
> > ==
> > require 'active_record/version'
> > # Be sure to restart your server when you modify this file
>
> You should probably stick it after the line requires boot.rb - that
> way the rails gems should already be on the load path
>
> Fred

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: How to make has_attached_file dynamic depending on form values

2010-10-06 Thread Christian Fazzini
anyone?

On Oct 3, 3:37 am, Christian Fazzini 
wrote:
> I am using Paperclip by the way
>
> On Oct 3, 3:36 am, Christian Fazzini 
> wrote:
>
> > My form submits with a column called stream_type, which can either be
> > "full", "30secs" or "90secs".
>
> > How can i set it so that it sets has_attached_file according to the
> > form value stream_type?
>
> > --
>
> > Model class looks like this:
>
> >   has_attached_file :media,
> >                     :styles => { :original =>
> >  },
> >                     :url => '/assets/artists/:artist_id/
> > songs/:id/:style.:extension',
> >                     :path => ':rails_root/public/assets/
> > artists/:artist_id/songs/:id/:style.:extension',
> >                     :processors => [:process_audio]
>
> > --
>
> > So for example, if my form submits with stream_type = 90secs, then
> > has_attached_file will look like:
>
> >   has_attached_file :media,
> >                     :styles => { :original => '30' },
> >                     :url => '/assets/artists/:artist_id/
> > songs/:id/:style.:extension',
> >                     :path => ':rails_root/public/assets/
> > artists/:artist_id/songs/:id/:style.:extension',
> >                     :processors => [:process_audio]
>
>

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Start mongrel in ssh session and then exit in Ubuntu 10.04

2010-10-06 Thread Jeffrey L. Taylor
Quoting Duy Lam :
> Hi all,
> 
> I'm deploying a Rails application in a Ubuntu 10.04 server with
> mongrel web server. I connect to server and do stuffs in a ssh client
> (PuTTY). And I'm getting stuck with a strange issue:
> 1. After I connected to server, I start mongrel with : $ start-stop-
> daemon -S -d . -x script/server -b -- -p 8080
> 2. I left the ssh console and launch firefox from my Win7 box and open
> the website, it runs well. I can see the homepage
> 3. I go back to the ssh console. Close the terminal (and window too)
> it by : $ exit
> 4. Then in firefox, I press F5 to refresh and nothing shows up. It's
> just an empty space in whole webpage. I tried to use addon to capture
> the HTTP data and see that the server returns nothing , even HTTP
> headers
> 
> I thought that using start-stop-daemon command could help me run
> mongrel as daemon and then I can exit my session just as apache does.
> But it doesn't work.
> 

Possible workaround, ssh into server, at shell type "screen", hit space bar,
start server, type control-A control-D to detach from screen, logout of SSH
session.  Later you can log in and type "screen -r" to resume the screen
session.

I also find this very useful for long operations on remote systems that might
lose the connection (e.g. dialup and wifi).

HTH,
  Jeffrey

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Passing a hash from the model to the view

2010-10-06 Thread Robert Walker
Leonel *-* wrote:
> CONTROLLER
>   @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
> minutes" => "90", "2 hours" => "120"}

Where did you put this line? You're not showing any context.

> ERROR
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.map
> Extracted source (around line #20):
> 
> 17:   
> 18:   
> 19: <%= f.label :duration %>
> 20: <%= f.select ("duration", @durations.map {|d| [d.id, d.name]}, 
> :prompt => "Select") %>
> 21:   
> 22:   
> 23: <%= f.label :cost %>

Which template file is this from? Guessing it's in the the context of an 
edit.html.erb or new.html.erb.

Also guessing that you probably need to have that hash available to both 
the edit and new pages so you will probably need to set @durations using 
a before_filter:

before_filter load_durations, :only => [ :new, :edit ]

private
def load_durations
@durations = { "30 minutes" => "30",
   "1 hour" => "60",
   "1 hour 30 minutes" => "90",
   "2 hours" => "120" }
end
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Passing a hash from the model to the view

2010-10-06 Thread Marnen Laibow-Koser
Leonel *-* wrote:
 And why not use Haml?
>>> I don't know what that is
>> 
>> But you know what Google is, right? :)  Look it up!
> 
> haha, thanks, already did. HAML sounds good
> 
>> Where in the controller are you setting the variable?  Let's see the 
>> entire controller method that you're using.
> 
> I was setting it at the top of the controller, thinking it would 
> propagate to all the methods.
> 
> class ServicesController < ApplicationController
>   @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
> minutes" => "90", "2 hours" => "120"}

Yeah, I thought you might be doing that.  That won't work.

The problem is that @instance_variables are always instance variables of
self.  Inside an instance method (and controller actions are instance
methods), self is an instance of ServicesController.

Outside an instance method, however, self is the class object itself!
(That is, self is the object called ServicesController, which is an
instance of class Class).  Thus, you're setting the instance variable on
the wrong object.

> 
>   def index
> @services = Service.all
> ...
> end
> 
> But then I moved it inside the method.
> 
>   def new
> @service = Service.new
> @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
> minutes" => "90", "2 hours" => "120"}
> 
> 
> It gave me another descriptive error message that led me to fix the form 
> partial.
> 
>   
> <%= f.label :duration %>
> <%= f.select ("duration", @durations, :prompt => "Select") %>
>   
> 
> And it works now! XD

Exactly!  You're defining the variable in the right place, so it's
getting copied to the view.

> 
> Sorry, I know this is probably very basic but I just started yesterday 
> my first Rails application outside of a tutorial book.

Congrаtulations and good luck!  Remember to do all development
test-first (I recommend RSpec, Cucumber, and Machinist for this), and
set up version control (preferably Git) if you haven't done so already.

> 
> Thanks for pointing me in the right direction! :D

You're welcome.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Passing a hash from the model to the view

2010-10-06 Thread Leonel *-*
>>> And why not use Haml?
>> I don't know what that is
> 
> But you know what Google is, right? :)  Look it up!

haha, thanks, already did. HAML sounds good

> Where in the controller are you setting the variable?  Let's see the 
> entire controller method that you're using.

I was setting it at the top of the controller, thinking it would 
propagate to all the methods.

class ServicesController < ApplicationController
  @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
minutes" => "90", "2 hours" => "120"}

  def index
@services = Service.all
...
end

But then I moved it inside the method.

  def new
@service = Service.new
@durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
minutes" => "90", "2 hours" => "120"}


It gave me another descriptive error message that led me to fix the form 
partial.

  
<%= f.label :duration %>
<%= f.select ("duration", @durations, :prompt => "Select") %>
  

And it works now! XD

Sorry, I know this is probably very basic but I just started yesterday 
my first Rails application outside of a tutorial book.

Thanks for pointing me in the right direction! :D
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Converting an Existing Website: Removing Duplicate Meta Data

2010-10-06 Thread Christine Nyb
Marnen Laibow-Koser wrote:

> What's an example of what you're seeing, and how is it not what you 
> want?

It's just a message saying pages have duplicate title tags and meta data 
and that each page should be unique.

> This may be a Google Webmaster Tools question, not a Rails one.

The only information I could find through that route was regarding 
multiple domains with duplicate information. I was just wondering if 
there was a way to handle it with rails.

Thanks for your suggestion.  Right now it doesn't appear to be affecting 
search engine ranking.  This is my site and it is not a commercial site 
so that's why I decided to convert it first as a test.

I do have one for a local business that needs to be converted.  The rest 
are new sites and were published with ruby on rails.

Thanks,

Christine

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Passing a hash from the model to the view

2010-10-06 Thread Marnen Laibow-Koser
Leonel *-* wrote:
> Marnen Laibow-Koser wrote:
>> Why not just use collection_select?
> According to 
> http://shiningthrough.co.uk/Select-helper-methods-in-Ruby-on-Rails "Use 
> select when you require a basic drop-down selection box populated with 
> data not sourced from a database"

You're right...I was thinking collection_select would work with a Hash, 
but of course it won't.

> 
>> And why not use Haml?
> I don't know what that is

But you know what Google is, right? :)  Look it up!

> 
>> Of course you did!  The view has no access to model instance variables. 
>> If you want to use @durations in the view, you'll need to set it in the 
>> *controller*, not the model.  Rails copies controller instance variables 
>> to the view.
> I just tried it from the controller and gives me same error message.
> 
> CONTROLLER
>   @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
> minutes" => "90", "2 hours" => "120"}
> 
> ERROR
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.map
> Extracted source (around line #20):
> 
> 17:   
> 18:   
> 19: <%= f.label :duration %>
> 20: <%= f.select ("duration", @durations.map {|d| [d.id, d.name]}, 
> :prompt => "Select") %>
> 21:   
> 22:   
> 23: <%= f.label :cost %>

Where in the controller are you setting the variable?  Let's see the 
entire controller method that you're using.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Passing a hash from the model to the view

2010-10-06 Thread Leonel *-*
Marnen Laibow-Koser wrote:
> Why not just use collection_select?
According to 
http://shiningthrough.co.uk/Select-helper-methods-in-Ruby-on-Rails "Use 
select when you require a basic drop-down selection box populated with 
data not sourced from a database"

> And why not use Haml?
I don't know what that is

> Of course you did!  The view has no access to model instance variables. 
> If you want to use @durations in the view, you'll need to set it in the 
> *controller*, not the model.  Rails copies controller instance variables 
> to the view.
I just tried it from the controller and gives me same error message.

CONTROLLER
  @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30 
minutes" => "90", "2 hours" => "120"}

ERROR
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map
Extracted source (around line #20):

17:   
18:   
19: <%= f.label :duration %>
20: <%= f.select ("duration", @durations.map {|d| [d.id, d.name]}, 
:prompt => "Select") %>
21:   
22:   
23: <%= f.label :cost %>

> No such thing as an "instance hash".  Did you mean an instance variable 
> that happens to contain a Hash?

Haha, yes, sorry, that's what I meant
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Error on running unity test: "no such file to load -- 'active_record/version'"

2010-10-06 Thread Frederick Cheung


On Oct 6, 1:32 pm, Fabrício Dias  wrote:
> Here it goes, Fred:
> ==
> require 'active_record/version'
> # Be sure to restart your server when you modify this file
>

You should probably stick it after the line requires boot.rb - that
way the rails gems should already be on the load path

Fred

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: How RoR handles multiple sub-websites under one host?

2010-10-06 Thread radhames brito
>
> When I follow through the tutorial on setup Ruby and Rails, I notice
> that the "scaffold" is creating app folder, config folders, etc. for
> single website only.
>
> To simulate my current directory structure, I suppost to create
> folers:
> /my_rails_root/sub_web_1/
> /my_rails_root/sub_web_2/
> (and so on...)
>
> and "scaffold" to each of them.
>


@crab

You are confusing what a rails app is , is not the same as an app in iis, in
iis the concept of apps exist to separate the webconfig file, so that each
application's configuration wont interfere with the other. Rails app's
folder is part of an standardization and there is not an equivalent, you
would be closer if you think of your rails all as the entire project folder.


On Tue, Oct 5, 2010 at 10:29 PM, crab  wrote:

> Hi Marnen,
>
> > > My question is, how can I start one "ruby server" and use one config
> > > for multiple sub-websites?
> >
>
Rails uses standardization so  configuration is not what you are thinking it
is you are applying again iis concepts.


I am working for university and there are nearly a hundred of sub-


websites under my host.
> Running ruby server instances and maintaining config files of that
> amount may not be feasible for me.
>
> Actually, we are currently using ColdFusion which has a admin console
> to handle the application server settings.
> I want to keep the practice as similar as possible.
>
>
> apparently what you want is a GUI for administration?



>
> Oh, yeah!  Phusion Passenger is useful.  I've heard of it.
>
> You say useful :), let me put it this way, it can take you days to set up
an IIS server with rails just because passenger does not run
on windows( or IIS), but it will take you not more than 10 minutes to set it
up on an apache/ubuntu box.



> But (very) unfortunately, our server config is Windows-base, using IIS
> as web server, and database is MS-SQL...
>

No one serius about web hosting is running on windows / IIS , maybe only
microsoft, but i wouldnt be 100% sure they are.
I use to host sites on iis and its a nigthamare compared to hosting on
apache/ubuntu/passenger


> It seems to be quite a tough job to introduce RoR to my workplace
> under this environment.
> I have to make it!
>

The thing is your original question is a web server issue not a rails issue,
so the main problem is that 1 you are using windows and 2 you are using IIS.


Making rails run on iis is complex and requires that you buy a special of
software(a dll). Last time i checked you needed to set IIs as a proxy with
an apache server behind running a mongrel cluster that uses a load balancing
middleware an a reverse proxy rewriting dll.

About indroducing rails in your work, start by stating the open source
nature of rails, setting up IIS and paying for support like MS wants you to
every now and then can cost around US$1,000 on the initial setup, calling
and expert is expensive, installing any additional module is expensive, also
IIS(MS technology in general) is always late to the party and they are
always behind in technology/security, also most vulnerabilities are found
there faster than in other platforms and lastly, viruses, having to pay
hundreds for an antivirus that at the end will never give you 100%
protection. Sum it all up and you will see that hosting on windows/iis can
cost around US$2,000 per server and lots more if you are using .NET and
bought visual studio (cost estimations are taken from where i live :) ) on
the other side, ubuntu/apache/passenger/RoR  cost $US 0.00 .

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Converting an Existing Website: Removing Duplicate Meta Data

2010-10-06 Thread Marnen Laibow-Koser
Christine Nyb wrote:
> Hi,
> 
> I have searched the forum to see if this has come up before.  If it has
> and I missed it I am sorry.
> 
> I'm fairly new to Ruby on Rails and have converted an existing site.  To
> avoid annoying redirects and disrupting search engine results I updated
> the routes.rb file so that the old file name renders the correct rhtml
> file.  For example, photos.html renders /photos.
> 
> It works but the problem is that Google Webmaster Tools sees duplicate
> meta data and titles for each page. 

What's an example of what you're seeing, and how is it not what you 
want?

> I would really appreciate
> information on how to correct this. I have been trying to figure out how
> to get google to ignore .html files or treat them as duplicate data but
> have had no luck so far.

This may be a Google Webmaster Tools question, not a Rails one.

But...you could set things up so that instead of photos.html routing to 
the same place as photos, it simply makes a 301 or 302 redirect. 
Presumably Google will then understand that the two URLs are the same 
page, though you should check their docs to make sure.  And for human 
users, the browsing experience will be essentially the same as before.

> 
> Thanks,
> 
> Christine

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Passing a hash from the model to the view

2010-10-06 Thread Marnen Laibow-Koser
Leonel *-* wrote:
> I'm trying to display a drop-down menu by using an instance variable
> from a model.
[...]
> Now, I want to populate the values from the model like this
> @durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30
> minutes" => "90", "2 hours" => "120"}
> 
> Then in the form partial I have this
> 
>   <%= f.label :duration %>
>   <%= f.select ("duration", @durations.map {|d| [d.id, d.name]}, :prompt
> => "Select") %>

Why not just use collection_select?

And why not use Haml?

> 
> 
> I get this error:
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.map

Of course you did!  The view has no access to model instance variables. 
If you want to use @durations in the view, you'll need to set it in the 
*controller*, not the model.  Rails copies controller instance variables 
to the view.

> 
> How can I initialize an instance variable or instance hash

No such thing as an "instance hash".  Did you mean an instance variable 
that happens to contain a Hash?

> and then use
> it on the form for the drop-down menu?

By setting it in the controller.  If this is at all confusing, you may 
want to review the Rails Guides or other basic reference.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread Marnen Laibow-Koser
Again: please quote when replying!

jrq wrote:
> By "avoid supplementing the database end of things",  I mean I want to
> avoid adding more tables or databases to the database engine,
> inserting an additional database layer.

But that's the right way to do it if you can't just get rid of the EAV 
schema.  There is no benefit to avoiding DB objects just for the sake of 
avoiding DB objects.

> 
> Yes, I'm currently intending to "munge" the unorganized fields into a
> string, and deal with the parsing/processing at another stage.  yes,
> it's inefficient, but it's a relatively small amount of processing,

It's not just inefficient; it will be inconvenient.  Don't do it.

> and hopefully it will get me to where I need to be within a short
> amount of time, which is a factor in this situation.

No.  It will just complicate your life immensely.  It may look simpler 
now, but once you try to do anything non-trivial, I think you'll find 
that it's a lot harder.

> 
> By "not preserving record integrity", I mean that I am not updating
> any of these records, it's read-only.  I want to pull the data and
> generate reports, both for screen and CSV stream.

Then do it right and transform the data into a non-EAV representation 
once you pull it.

> 
> Yes, most of the processing would be in the Model, not the Controller,
> but since the model is not a good representation of the existing
> database schema, there's going to be some fudging going on.

Then write a model that *is* a good representation of it (perhaps 
supplementing or completely ditching ActiveRecord).


>  The
> question is whether it's worth bothering to model the final data
> output at all.

Of course it is.  That way you can manipulate it more easily than with 
string parsing.

> 
> I know that helpers are for presentation formatting, which is why I
> specified that the helper process would be for the "screen".
> 
> Thanks.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Problem writing to database using form_for

2010-10-06 Thread Jim Burgess
Hi Luke,

Thanks very much for the reply.
You pointed me in exactly the right direction to solve my problem!!

> Another approach might be to pass this value from the new action to the 
> create action through the form using a hidden field.

I tried this already. This had the disadvantage that the hidden field 
was never up-to-date as it was set during validation and thus always 
contained the value of the previous submission.

> blah = Blah.new(params[:blah])
> 
> #now you have a instance of Blah.
> 
> if blah.save
>   #now you have access to the non represented field
>   blah.non_represented_field
> end

This on the other hand, sorted me right out.
I changed it slightly to:

applicant = Applicant.new(params[:applicant])
if applicant.valid?
  #now I have access to the field I need
  do_stuff_with_non_represented_field
  applicant.save
end

What I was actually using this field for was to create a hash of all 
submitted values, compare it to the hash of the previous record and thus 
prevent double data submission. And it works wonderfully.

Thanks very much for your help.
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: List of html_options available

2010-10-06 Thread Maksim Gudovsikov
> Thanks, I hadn't noticed it. But it seems there are other that are not 
> normal attributes.
> 
> For example, for select (drop-down menu) you have :prompt => "Select", 
> which is not a normal select attribute.

Hmm, you're right. I think here is something helpful:

http://rubydoc.info/docs/rails/2.3.8/ActionView/Helpers/FormOptionsHelper


http://rubydoc.info/ is imho the best ruby and rails docs on the net.
Maybe it helps you next time you search something.

Max.



> Maksim Gudovsikov wrote:
>> Hi,
>>
>> html_options are just normal attributes you write on to the html-tags
>> like: class, style, onchange and so on.
>>
>> Greets, Max.
>>
>> Am 06.10.2010 16:54, schrieb Leonel *-*:
>>> Can somebody please point me to a place in a documentation where I can
>>> find a complete list for the different options for html_options
>>> parameter?
>>
>> --
>> Maksim Gudovsikov
>> webit! Gesellschaft f�r neue Medien mbH
>> Schnorrstra�e 76 | 01069 Dresden
>> Telefon +49 351 46766-0 | Telefax +49 351 46766-66
>> gudovsi...@webit.de | www.webit.de
>>
>> Amtsgericht Dresden | HRB 15422
>> USt-ID DE 193477690
>> Gesch�ftsf�hrer Sven Haubold
> 

-- 
Maksim Gudovsikov
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
gudovsi...@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
USt-ID DE 193477690
Geschäftsführer Sven Haubold

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: List of html_options available

2010-10-06 Thread Leonel *-*
Thanks, I hadn't noticed it. But it seems there are other that are not 
normal attributes.

For example, for select (drop-down menu) you have :prompt => "Select", 
which is not a normal select attribute.

Maksim Gudovsikov wrote:
> Hi,
> 
> html_options are just normal attributes you write on to the html-tags
> like: class, style, onchange and so on.
> 
> Greets, Max.
> 
> Am 06.10.2010 16:54, schrieb Leonel *-*:
>> Can somebody please point me to a place in a documentation where I can
>> find a complete list for the different options for html_options
>> parameter?
> 
> --
> Maksim Gudovsikov
> webit! Gesellschaft f�r neue Medien mbH
> Schnorrstra�e 76 | 01069 Dresden
> Telefon +49 351 46766-0 | Telefax +49 351 46766-66
> gudovsi...@webit.de | www.webit.de
> 
> Amtsgericht Dresden | HRB 15422
> USt-ID DE 193477690
> Gesch�ftsf�hrer Sven Haubold

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Passing a hash from the model to the view

2010-10-06 Thread Leonel *-*
I'm trying to display a drop-down menu by using an instance variable
from a model.

THIS WORKS...


  <%= f.label :duration %>
  <%= f.select ("duration", {"30 minutes" => "30", "1 hour" => "60"},
:prompt => "Select") %>


THIS DOESN'T WORK...

Now, I want to populate the values from the model like this
@durations = {"30 minutes" => "30", "1 hour" => "60", "1 hour 30
minutes" => "90", "2 hours" => "120"}

Then in the form partial I have this

  <%= f.label :duration %>
  <%= f.select ("duration", @durations.map {|d| [d.id, d.name]}, :prompt
=> "Select") %>


I get this error:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.map

How can I initialize an instance variable or instance hash and then use
it on the form for the drop-down menu?
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] List of html_options available

2010-10-06 Thread Maksim Gudovsikov
Hi,

html_options are just normal attributes you write on to the html-tags
like: class, style, onchange and so on.

Greets, Max.

Am 06.10.2010 16:54, schrieb Leonel *-*:
> I've noticed lots of people online complain about not good documentation
> for Rails. I'm a PHP programmer but I'm a newbie on Rails.
> 
> I'm creating a form with a drop-down menu. I finally got to do it. I
> noticed there is a html_options parameter for select. I was curious as
> to what other html_options are available but couldn't find a list of
> options. I have been looking for it at the api
> http://api.rubyonrails.org but can't seem to find it. Maybe I'm not
> looking in the right places.
> 
> Can somebody please point me to a place in a documentation where I can
> find a complete list for the different options for html_options
> parameter?

-- 
Maksim Gudovsikov
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
gudovsi...@webit.de | www.webit.de

Amtsgericht Dresden | HRB 15422
USt-ID DE 193477690
Geschäftsführer Sven Haubold

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] List of html_options available

2010-10-06 Thread Hassan Schroeder
On Wed, Oct 6, 2010 at 7:54 AM, Leonel *-*  wrote:

> I noticed there is a html_options parameter for select.

> Can somebody please point me to a place in a documentation where I can
> find a complete list for the different options for html_options
> parameter?

http://www.w3.org/TR/html401/interact/forms.html#edef-SELECT

HTH,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com
twitter: @hassan

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] List of html_options available

2010-10-06 Thread Leonel *-*
I've noticed lots of people online complain about not good documentation
for Rails. I'm a PHP programmer but I'm a newbie on Rails.

I'm creating a form with a drop-down menu. I finally got to do it. I
noticed there is a html_options parameter for select. I was curious as
to what other html_options are available but couldn't find a list of
options. I have been looking for it at the api
http://api.rubyonrails.org but can't seem to find it. Maybe I'm not
looking in the right places.

Can somebody please point me to a place in a documentation where I can
find a complete list for the different options for html_options
parameter?
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: something is removing my whitespace

2010-10-06 Thread bingo bob
Just to confirm, Walter's interpretation of what I'm seeing is 
absolutely right. The lack of the newline at the start is significant as 
it means the first heading doesn't get rendered as HTML it just gets put 
out as "h2. foo", which is, well, rubbish - my investigations continue. 
Something funky is occuring here.
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread jrq
By "avoid supplementing the database end of things",  I mean I want to
avoid adding more tables or databases to the database engine,
inserting an additional database layer.

Yes, I'm currently intending to "munge" the unorganized fields into a
string, and deal with the parsing/processing at another stage.  yes,
it's inefficient, but it's a relatively small amount of processing,
and hopefully it will get me to where I need to be within a short
amount of time, which is a factor in this situation.

By "not preserving record integrity", I mean that I am not updating
any of these records, it's read-only.  I want to pull the data and
generate reports, both for screen and CSV stream.

Yes, most of the processing would be in the Model, not the Controller,
but since the model is not a good representation of the existing
database schema, there's going to be some fudging going on.  The
question is whether it's worth bothering to model the final data
output at all.

I know that helpers are for presentation formatting, which is why I
specified that the helper process would be for the "screen".

Thanks.


On Oct 6, 10:35 am, Marnen Laibow-Koser  wrote:
> Please quote when replying; otherwise, the discussion becomes difficult
> to follow.
>
> jrq wrote:
> > Good and reasonable suggestions.  I'd rather avoid supplementing the
> > database end of things.  
>
> I'm not sure what you mean by this.
>
> Basically, if you're going to use Rails, you have to make sure that it
> and the DB understand each other.
>
> > The complete data set is fairly small <20,000
> > rows and queries are likely to only return 1,000 rows at a time.  I
> > don't think the string parsing is that complex, a couple of
> > seconds would be OK, 10 seconds, not so much.  3
>
> But you'd be munging all the fields together in the query, then
> separating them in the app.  That's a lot of unnecessary string
> processing.  It would be better to avoid ti.
>
> > It's for read-only
> > reports, so I don't really care about preserving the record integrity.
>
> Huh?
>
> > I'm wondering whether it makes sense to do half the processing in the
> > controller/model,
>
> Controllers shouldn't do processing.
>
> > and half in some helper (for the screen aspect).
>
> Unlikely.  Dealing with the DB is really the job of the model.  Helpers
> are only for presentation formatting.
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Converting an Existing Website: Removing Duplicate Meta Data

2010-10-06 Thread Christine Nyb
Hi,

I have searched the forum to see if this has come up before.  If it has
and I missed it I am sorry.

I'm fairly new to Ruby on Rails and have converted an existing site.  To
avoid annoying redirects and disrupting search engine results I updated
the routes.rb file so that the old file name renders the correct rhtml
file.  For example, photos.html renders /photos.

It works but the problem is that Google Webmaster Tools sees duplicate
meta data and titles for each page. I would really appreciate
information on how to correct this. I have been trying to figure out how
to get google to ignore .html files or treat them as duplicate data but
have had no luck so far.

Thanks,

Christine
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Good idea to send encrypted password with activation link

2010-10-06 Thread David Kahn
PS, this is the authlogic explanation. Their point is that the token
expires, as unless you put in other safeguards if the encrypted password
might be able to be used again, for security purposes it really should be
reset. I think my prev explanation is probably highly unlikely.

http://rdoc.info/github/binarylogic/authlogic/master/Authlogic/ActsAsAuthentic/PerishableToken

On Wed, Oct 6, 2010 at 9:32 AM, David Kahn wrote:

> I recently started with Authlogic and it specifically uses a specifically
> generated temporary token for such so that it is not necessary to send an
> encrypted password or anything else. I think in general security wise if you
> are using encryption that you dont want a lot of your encrypted data
> floating around as given a large enough sample available publicaly
> theoretically it could be possible to determine your encryption keys.
>
> David
>
>
> On Wed, Oct 6, 2010 at 7:50 AM, radhames brito  wrote:
>
>>
>>
>> On Wed, Oct 6, 2010 at 8:41 AM, Ar Chron  wrote:
>>
>>> Felix Samy wrote:
>>> > Is this good idea to send activation link with encrypted password
>>>
>>  then encrypted password?
>> For what??
>>
>>  --
>> 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 rubyonrails-t...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> rubyonrails-talk+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>
>

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Problem writing to database using form_for

2010-10-06 Thread Luke Cowell
On 2010-10-05, at 10:41 PM, Jim Burgess wrote:

> 
>> validate do |applicant|
>>  errors.add_to_base("Things must check out!") unless 
>> applicant.check_things
>> end
>> 
>> def before_save
>>  applicant.non_represented_field = 123456789
>> end
>> 
>> before_save will only be called if your validations pass, so 
>> non_represented_field will only be assigned to valid records.
> 
> Hi,
> 
> Thanks for the reply.
> 
> Sorry, I don't think I expressed myself very well.
> 
> When I submit the form, every value the applicant has entered is 
> validated and passed to the controller. That means that if they enter a 
> value in the email field (for example) I can access this value in the 
> controller in the params hash, regardless of whether validation failed 
> or passed.
> 
> As this 'non-represented' field is only getting set after a successful 
> validation, it is not available in the params hash until everything has 
> been filled out correctly. Before that it always shows as nil.
> 
> I would like to set this value in my model with every form submission 
> (it is a hash which is always a different value per submission) so that 
> it is always available in the params has in the controller.
> 
> I really appreciate any help.
> 

Perhaps you could post the pertinent code ? Do you have validation checks in 
the form (via javascript) or just the ones in model ?

blah = Blah.new(params[:blah])

#now you have a instance of Blah.

if blah.save
  #now you have access to the non represented field
  blah.non_represented_field
end

Another approach might be to pass this value from the new action to the create 
action through the form using a hidden field.

Luke


-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread Marnen Laibow-Koser
Please quote when replying; otherwise, the discussion becomes difficult 
to follow.

jrq wrote:
> Good and reasonable suggestions.  I'd rather avoid supplementing the
> database end of things.  

I'm not sure what you mean by this.

Basically, if you're going to use Rails, you have to make sure that it 
and the DB understand each other.

> The complete data set is fairly small <20,000
> rows and queries are likely to only return 1,000 rows at a time.  I
> don't think the string parsing is that complex, a couple of
> seconds would be OK, 10 seconds, not so much.  3

But you'd be munging all the fields together in the query, then 
separating them in the app.  That's a lot of unnecessary string 
processing.  It would be better to avoid ti.

> It's for read-only
> reports, so I don't really care about preserving the record integrity.

Huh?

> I'm wondering whether it makes sense to do half the processing in the
> controller/model,

Controllers shouldn't do processing.

> and half in some helper (for the screen aspect).

Unlikely.  Dealing with the DB is really the job of the model.  Helpers 
are only for presentation formatting.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Good idea to send encrypted password with activation link

2010-10-06 Thread David Kahn
I recently started with Authlogic and it specifically uses a specifically
generated temporary token for such so that it is not necessary to send an
encrypted password or anything else. I think in general security wise if you
are using encryption that you dont want a lot of your encrypted data
floating around as given a large enough sample available publicaly
theoretically it could be possible to determine your encryption keys.

David

On Wed, Oct 6, 2010 at 7:50 AM, radhames brito  wrote:

>
>
> On Wed, Oct 6, 2010 at 8:41 AM, Ar Chron  wrote:
>
>> Felix Samy wrote:
>> > Is this good idea to send activation link with encrypted password
>>
>  then encrypted password?
> For what??
>
>  --
> 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 rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: what is that get in routes?

2010-10-06 Thread Luke Cowell
What command line did you use to generate it ? If you specify only one action I 
think it assumes that it's a GET request even though destroy would usually 
correspond with a DELETE request. I suggest you delete the line and forget 
about it.

Luke

On 2010-10-06, at 1:46 AM, Mauro wrote:

> why rails put automatically that get "operator_session/destroy"?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread jrq
Good and reasonable suggestions.  I'd rather avoid supplementing the
database end of things.  The complete data set is fairly small <20,000
rows and queries are likely to only return 1,000 rows at a time.  I
don't think the string parsing is that complex, a couple of
seconds would be OK, 10 seconds, not so much.  It's for read-only
reports, so I don't really care about preserving the record integrity.
I'm wondering whether it makes sense to do half the processing in the
controller/model, and half in some helper (for the screen aspect).

On Oct 6, 10:03 am, Marnen Laibow-Koser  wrote:
> jrq wrote:
> > I've inherited an EAV database and there's really no option to remodel
> > it.  
>
> Why not?  Are others depending on the existing schema?
>
> > Data is stored as key_name, key_value pairs
> > Trying to return a meaningful, unified recordset is far too complex to
> > be efficient.
> > I've decided to make use of the MySQL GROUP_CONCAT, and CONCAT_WS
> > functions to return a fast query result, with the consolidated fields
> > as one string.
> > The final data is to be displayed and downloaded (CSV), but not all
> > fields will be available for each "row", which makes serialization
> > awkward.  I can't decide where the "heavy lifting" should go to parse
> > and process this data for screen and download.
>
> > Does anyone have a good strategy for this?
>
> If you can't remodel the DB, decline the project. :)
>
> If you can't decline the project, export the data into a reasonable
> schema (a non-SQL database like MongoDB may be a good option here).  A
> Google search also turned up the acts_as_eav_model plugin, but I know
> nothing about it.
>
> Another alternative: build a RESTful service (perhaps without Rails) on
> top of the EAV database, then connect Rails to it through
> ActiveResource.
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: something is removing my whitespace

2010-10-06 Thread John T.
Walter Davis wrote:
> But he's running this through RedCloth, and whitespace is significant
> there, and renders into HTML. He's seeing
...
> Walter

Ahhh.. My bad :) Missed the RedCloth reference.  Resume party ;)
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread Marnen Laibow-Koser
Marnen Laibow-Koser wrote:
> jrq wrote:
>> I've inherited an EAV database and there's really no option to remodel
>> it.  
[...]
> If you can't remodel the DB, decline the project. :)

Hmmm.  This question and others like 
http://www.ruby-forum.com/topic/218057 are making me start to think that 
I should put the effort into that ORM library I've been meaning to try 
to write...

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: something is removing my whitespace

2010-10-06 Thread Walter Lee Davis
But he's running this through RedCloth, and whitespace is significant  
there, and renders into HTML. He's seeing


~~~

h2. Some Header

Some paragraph.
~~~

collapse to

~~~
h2. Some Header

Some paragraph.
~~~

and that lack of leading newline is somehow significant to his  
RedCloth conversion.


Walter

On Oct 6, 2010, at 9:11 AM, John T. wrote:


bingo bob wrote:
The more I think about this the more Fred's suggestion makes sense  
- I
suspect that mysql is somehow monkeying with the text on save,  
trimming

it at the top or removing CR characters or the like.

Is this normal? How can you control this behaviour, seems wierd  
that it

does this by default if this is indeed what's happening.


If you're trying to see blank lines and extra spaces on your web page,
and the output is not between  tags, the behavior of HTML will
collapse extra white space. Ex.:

A   Line   Like   This

will render as:

A Line Like This

and this:

hello

world

will render as:

hello world
--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails- 
t...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com 
.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en 
.




--
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dealing with an EAV database

2010-10-06 Thread Marnen Laibow-Koser
jrq wrote:
> I've inherited an EAV database and there's really no option to remodel
> it.  

Why not?  Are others depending on the existing schema?

> Data is stored as key_name, key_value pairs
> Trying to return a meaningful, unified recordset is far too complex to
> be efficient.
> I've decided to make use of the MySQL GROUP_CONCAT, and CONCAT_WS
> functions to return a fast query result, with the consolidated fields
> as one string.
> The final data is to be displayed and downloaded (CSV), but not all
> fields will be available for each "row", which makes serialization
> awkward.  I can't decide where the "heavy lifting" should go to parse
> and process this data for screen and download.
> 
> Does anyone have a good strategy for this?

If you can't remodel the DB, decline the project. :)

If you can't decline the project, export the data into a reasonable 
schema (a non-SQL database like MongoDB may be a good option here).  A 
Google search also turned up the acts_as_eav_model plugin, but I know 
nothing about it.

Another alternative: build a RESTful service (perhaps without Rails) on 
top of the EAV database, then connect Rails to it through 
ActiveResource.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Dealing with an EAV database

2010-10-06 Thread jrq
I've inherited an EAV database and there's really no option to remodel
it.  Data is stored as key_name, key_value pairs
Trying to return a meaningful, unified recordset is far too complex to
be efficient.
I've decided to make use of the MySQL GROUP_CONCAT, and CONCAT_WS
functions to return a fast query result, with the consolidated fields
as one string.
The final data is to be displayed and downloaded (CSV), but not all
fields will be available for each "row", which makes serialization
awkward.  I can't decide where the "heavy lifting" should go to parse
and process this data for screen and download.

Does anyone have a good strategy for this?

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Really need help with gems not being found

2010-10-06 Thread omnivore
Colin, I naturally did send Frederick Cheung (hope I have the name
right) thanks directly, although his answer did not actually solve the
problem, and reiterated advice that I also found on (IIRC)
stackoverflow. He did clue me in to checking the locations of ruby,
rake and gems, and I found another clue on another site, where a
similar problem was documented. Of course, I thanked that person
profusely. I think that's pretty much adequate, and if anyone here had
solved the problem, of course I would have thanked them. I understand
quite clearly how these exchanges work.

The point of my last post was that one respondent seemed more focussed
on topics irrelevant to my question, made remarks that were
gratuitously judgmental, and what he contributed was unhelpful to
others with a similar problem. Signal to noise is important, is it
not?

Other than that – and with no desire to extend this uneccesarily –
what point of etiquette did I miss, in your opinion?

On Oct 6, 2:56 am, Colin Law  wrote:
> On 6 October 2010 02:08, omnivore  wrote:
>
> > Solution was simple, once I found it. Change the bang line in the
> > rake.rb, found via 'which rake' to point to the ruby version that
> > houses the gems. Now things work.
>
> Don't bother thanking anyone for pointing you at the cause of the
> problem.  They are only in it for the money anyway.
>
> Colin

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: What is the best column time to store amount of hours

2010-10-06 Thread Leonel *-*
I guess you guys are right. I wanted to avoid the conversation if 
possible but your suggestions seem to be the way to go.

Thanks :)
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: something is removing my whitespace

2010-10-06 Thread John T.
bingo bob wrote:
> The more I think about this the more Fred's suggestion makes sense - I 
> suspect that mysql is somehow monkeying with the text on save, trimming 
> it at the top or removing CR characters or the like.
> 
> Is this normal? How can you control this behaviour, seems wierd that it 
> does this by default if this is indeed what's happening.

If you're trying to see blank lines and extra spaces on your web page, 
and the output is not between  tags, the behavior of HTML will 
collapse extra white space. Ex.:

A   Line   Like   This

will render as:

A Line Like This

and this:

hello

world

will render as:

hello world
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Mailing labels

2010-10-06 Thread Marnen Laibow-Koser
Bob Smith wrote:
> Any easy way to print on mailing labels that have 3 columns? I need
> these to fit in my laser printer. I have no trouble with single column
> labels, but I don't know how to make a partial display 3 times across
> a page with different records.

render :partial, :collection

For precision printing, you'll probably want to generate a PDF file 
using Prawn, wkhtmltopdf, or some other similar library.

> 
> Thanks
> 
> Bob 

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Sent from my iPhone
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: how to connect to microsoft sql server 6.5

2010-10-06 Thread pepe
Forgot to add database.yml configuration. Here it is:

your_environment_here:
  adapter:  sqlserver
  mode: odbc
  dsn:  your_dsn_name_here
  username: your_username_here
  password: your_password_here

There is no need to use host or port parameter since we're using a
DSN.

On Oct 5, 8:40 am, pepe  wrote:
> I only know about SQLServer 2005 and 2008, not 6.5. Anyway, here is a
> list of things I had to do to get a project working with 2005 using
> Ruby 1.8.6, Rails 2.3.5 and Mongrel as the web server. You might need
> to skip/change some of the steps. I hope it helps:
>
> 1.      Install Ruby (1.8.6):http://www.ruby-lang.org/en/downloads/
> 2.      Install rubygems:
>   a.    http://rubygems.org/pages/download(zip version)
>   b.    Unpack to a directory and cd there
>   c.    ruby setup.rb
> 3.      Install rails: gem install rails –v=2.3.5
> 4.      Install mongrel: gem install mongrel
> 5.      Install mongrel service: gem install mongrel_service
> 6.      Install SQL Server adapter: gem install activerecord-sqlserver-
> adapter
> 7.      Install ODBC gem: gem install odbc-rails
> 8.      Install authentication gem: gem install authlogic
> 9.      Install encryption gem: gem install attr_encrypted
> 10.     Install SQL Server Management utility (from Microsoft)
> 11.     Create SQL Server DB
> 12.     Create login in SQL Server
> 13.     Create DB user
> 14.     Create DSN in Windows:
> a.      Control Panel -> Adminstrative Tasks -> Data Sources (ODBC)
> b.      Click on System DSN -> Add
> c.      Select type SQL Server
>   i.    Name: *Give it a name*
>   ii.   Description: *Give it a description*
>   iii.  Server: Server name (*whatever name you can see in the SQL
> Server Management Utility*)
>   iv.   Use SQL Authentication
>
> On Oct 4, 5:11 pm, prinx  wrote:
>
> > Hi all,
> > i'm beginner in rails world...i try to connect my rails application on
> > a db sql server 6.5 without success, ca you help me?
> > i try odbc driver, jtds e activerecord-sqlserver-adapter but
> > nothing...
> > what are the right gems or the right sequence procedure?
>
> > thx
> > Prinx

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Good idea to send encrypted password with activation link

2010-10-06 Thread radhames brito
On Wed, Oct 6, 2010 at 8:41 AM, Ar Chron  wrote:

> Felix Samy wrote:
> > Is this good idea to send activation link with encrypted password
>
 then encrypted password?
For what??

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Viewing 404 in development

2010-10-06 Thread Anthony Foster
For what it's worth, I have solved this issue.  As opposed to localhost,
point your browser to your machines ip address, assuming your development is
local.

Otherwise you could rescue_action_locally to call rescue_action_in_public.

On Wed, Sep 22, 2010 at 4:10 PM, Anthony Foster
wrote:

> Hey,
>
> I'm doing a basic project in Ruby on Rails, and want to test my
> routing, and error pages. I'd like to do this in my development
> environment. I've gone into config/environments/development.rb and
> set:
>
> config.action_controller.consider_all_requests_local = false
>
> But when I go to an improper route, I don't get public/404.html
> rendered. I continue to get the routing error page:
>
> Routing Error
>
> No route matches "/badroute" with {:method=>:get}
>
> Is there a better way to check this? I'd like to see how rails handles
> the routing errors by default, and what the 404 will cover, than maybe
> add some complex error handling after.
>
> Thanks for the help!

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Good idea to send encrypted password with activation link

2010-10-06 Thread Ar Chron
Felix Samy wrote:
> Is this good idea to send activation link with encrypted password

Why would you want to send the encrypted password anywhere?
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: what is that get in routes?

2010-10-06 Thread Ar Chron
If you generated that controller then perhaps rails assumed a GET was 
the safest thing to default?
-- 
Posted via http://www.ruby-forum.com/.

-- 
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 rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Error on running unity test: "no such file to load -- 'active_record/version'"

2010-10-06 Thread Fabrício Dias
Here it goes, Fred:
==
require 'active_record/version'
# Be sure to restart your server when you modify this file

# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'

# Specifies gem version of Rails to use when vendor/rails is not
present
RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION

# Bootstrap the Rails environment, frameworks, and default
configuration
require File.join(File.dirname(__FILE__), 'boot')

Rails::Initializer.run do |config|
  # Settings in config/environments/* take precedence over those
specified here.
  # Application configuration should go into files in config/
initializers
  # -- all .rb files in that directory are automatically loaded.
  # See Rails::Configuration for more options.

  # Skip frameworks you're not going to use. To use Rails without a
database
  # you must remove the Active Record framework.
  # config.frameworks -=
[ :active_record, :active_resource, :action_mailer ]

  # Specify gems that this application depends on.
  # They can then be installed with "rake gems:install" on new
installations.
  # You have to specify the :lib option for libraries, where the Gem
name (sqlite3-ruby) differs from the file itself (sqlite3)
  # config.gem "bj"
  # config.gem "hpricot", :version => '0.6', :source => "http://
code.whytheluckystiff.net"
  # config.gem "sqlite3-ruby", :lib => "sqlite3"
  # config.gem "aws-s3", :lib => "aws/s3"

  # Only load the plugins named here, in the order given. By default,
all plugins
  # in vendor/plugins are loaded in alphabetical order.
  # :all can be used as a placeholder for all plugins not explicitly
named
  # config.plugins =
[ :exception_notification, :ssl_requirement, :all ]

  # Add additional load paths for your own custom dirs
  # config.load_paths += %W( #{RAILS_ROOT}/extras )

  # Force all environments to use the same logger level
  # (by default production uses :info, the others :debug)
  # config.log_level = :debug

  # Make Time.zone default to the specified zone, and make Active
Record store time values
  # in the database in UTC, and return them converted to the specified
local zone.
  # Run "rake -D time" for a list of tasks for finding time zone
names. Comment line to use default local time.
  config.time_zone = 'UTC'

  # The internationalization framework can be changed to have another
default locale (standard is :en) or more load paths.
  # All files from config/locales/*.rb,yml are added automatically.
  # config.i18n.load_path << Dir[File.join(RAILS_ROOT, 'my',
'locales', '*.{rb,yml}')]
  # config.i18n.default_locale = :de

  # Your secret key for verifying cookie session data integrity.
  # If you change this key, all old sessions will become invalid!
  # Make sure the secret is at least 30 characters and all random,
  # no regular words or you'll be exposed to dictionary attacks.
  config.action_controller.session = {
:session_key => '_shopcell_session',
:secret => 'f914e9b1bbdb829688de8512f...
9b1810a4e238a61dfd922dc9dd62521'
  }

  # Use the database for sessions instead of the cookie-based default,
  # which shouldn't be used to store highly confidential information
  # (create the session table with "rake db:sessions:create")
  config.action_controller.session_store = :active_record_store


  # Use SQL instead of Active Record's schema dumper when creating the
test database.
  # This is necessary if your schema can't be completely dumped by the
schema dumper,
  # like if you have constraints or database-specific column types
  # config.active_record.schema_format = :sql

  # Activate observers that should always be running
  # Please note that observers generated using script/generate
observer need to have an _observer suffix
  # config.active_record.observers
= :cacher, :garbage_collector, :forum_observer

#act_as_tagglable_on
config.gem "acts-as-taggable-on", :source => "http://
gemcutter.org", :version => '2.0.0.rc1'

#brazilian_rails
require 'brcpfcnpj'
end
END OF
ENVIRONMENT.RB==

If I remove the first line (require 'active_record/version'), I get
this error when running "ruby script/server":

==
...
...
...
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
Exiting
/home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:445:in `load_missing_constant':
uninitialized constant ActiveRecord::VERSION (NameError)
from /home/fabricio/.gem/ruby/1.8/gems/activesupport-2.2.2/lib/
active_support/dependencies.rb:77:in `const_missing'
from /var/lib/gems/1.8/gems/acts-as-taggable-on-2.0.0.rc1/lib/acts-as-
taggable-on.rb:6
from /usr/lib/ruby/1.8/rubygems/custom_requi

  1   2   >