[Rails] /bin/sh: ./miniruby: No such file or directory errror

2010-06-07 Thread Tushar Gandhi
Hi,
I am installing ruby 1.8.6 on feodra linux. I have download the
ruby-1.8.7.tar file. But whenever I am doing "make" it is giving an
error
"make[1]: *** [ossl_ssl.o] Error 1
make[1]: Leaving directory
`/home/rails_setup/ruby-1.8.7-p72/ext/openssl'
make: *** [all] Error 1
"
And when I am doing "make install" I am getting error
"/bin/sh: ./miniruby: No such file or directory"

Can anyone please help me out to solve this?

Thanks,
Tushar
-- 
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: Validate in controller or use Rails validations?

2010-06-07 Thread chewmanfoo
use them!  they encourage proper MVC

(duck behind something solid - I sense a flamewar cometh)

> As I prepare to add validations to my application, I am trying to
> decide if it would be better to write validation logic in the update/
> create controller methods or use Rails' validation methods.  In the
> former case, I would check the field values provided by the user
> before saving to the database and redirect back to the input URL if a
> validation fails.  The presence of so many built-in validation methods
> tells me there must be a good reason to use them.  Yet reading through
> the documentation I can't be sure what the benefit is.  I appreciate
> any guidance from the experts in this forum.
>
> Thanks in advance,
> Mark

-- 
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] Validate in controller or use Rails validations?

2010-06-07 Thread MarkB
As I prepare to add validations to my application, I am trying to
decide if it would be better to write validation logic in the update/
create controller methods or use Rails' validation methods.  In the
former case, I would check the field values provided by the user
before saving to the database and redirect back to the input URL if a
validation fails.  The presence of so many built-in validation methods
tells me there must be a good reason to use them.  Yet reading through
the documentation I can't be sure what the benefit is.  I appreciate
any guidance from the experts in this forum.

Thanks in advance,
Mark

-- 
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: string attributes not showing up in view

2010-06-07 Thread Ali Akhtarzada
What do you mean? What's wrong with them?

On Tue, Jun 8, 2010 at 4:55 PM, chewmanfoo  wrote:

> what's with the @first_name, @last_name?
>
> On Jun 7, 11:18 pm, Ali  wrote:
> > Hi,
> >
> > I have a user model with attributes first_name, last_name and email.
> >
> > In the view I'm looping though all the users and for each user
> > printing out the email add the full_name (full_name is a function in
> > the user model that returns both first and last names). The email
> > prints but the names do not and it's really weird. I have checked in
> > the script/console and verified that the values are actually inside
> > the user object (I only have one user object created with the
> > migration).
> >
> > What's even weirder is that when I call User.find_by_email "blah" and
> > it gives me back my user, the output in the console shows all the
> > fields, shows the first_name and last_name values as well. But in the
> > console if I do u.first_name, I get a nil return. If I do u.email, I
> > get the "blah" return. Any idea where I can start looking for a
> > problem?
> >
> > In the user.index.html.erb
> >
> > <% @users.each do |user| %>
> >   
> > <%= user.full_name %>
> > <%= user.email %>
> >   
> > <% end %>
> >
> > and in my User model:
> >
> >   def full_name
> > @first_name + " " + @last_name
> >   end
> >
> > Thanks in advance
>
> --
> 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: string attributes not showing up in view

2010-06-07 Thread chewmanfoo
what's with the @first_name, @last_name?

On Jun 7, 11:18 pm, Ali  wrote:
> Hi,
>
> I have a user model with attributes first_name, last_name and email.
>
> In the view I'm looping though all the users and for each user
> printing out the email add the full_name (full_name is a function in
> the user model that returns both first and last names). The email
> prints but the names do not and it's really weird. I have checked in
> the script/console and verified that the values are actually inside
> the user object (I only have one user object created with the
> migration).
>
> What's even weirder is that when I call User.find_by_email "blah" and
> it gives me back my user, the output in the console shows all the
> fields, shows the first_name and last_name values as well. But in the
> console if I do u.first_name, I get a nil return. If I do u.email, I
> get the "blah" return. Any idea where I can start looking for a
> problem?
>
> In the user.index.html.erb
>
> <% @users.each do |user| %>
>   
>     <%= user.full_name %>
>     <%= user.email %>
>   
> <% end %>
>
> and in my User model:
>
>   def full_name
>     @first_name + " " + @last_name
>   end
>
> Thanks in advance

-- 
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] string attributes not showing up in view

2010-06-07 Thread Ali
Hi,

I have a user model with attributes first_name, last_name and email.

In the view I'm looping though all the users and for each user
printing out the email add the full_name (full_name is a function in
the user model that returns both first and last names). The email
prints but the names do not and it's really weird. I have checked in
the script/console and verified that the values are actually inside
the user object (I only have one user object created with the
migration).

What's even weirder is that when I call User.find_by_email "blah" and
it gives me back my user, the output in the console shows all the
fields, shows the first_name and last_name values as well. But in the
console if I do u.first_name, I get a nil return. If I do u.email, I
get the "blah" return. Any idea where I can start looking for a
problem?

In the user.index.html.erb

<% @users.each do |user| %>
  
<%= user.full_name %>
<%= user.email %>
  
<% end %>

and in my User model:

  def full_name
@first_name + " " + @last_name
  end

Thanks in advance

-- 
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: Can a dropdown be used to select additional form fi

2010-06-07 Thread Marnen Laibow-Koser
Bill Walton wrote:
> On Mon, Jun 7, 2010 at 4:22 PM, Marnen Laibow-Koser
>  wrote:
>> Build all the forms in advance, inside hidden divs. �Then show one div
>> or another based on dropdown selection. �Very simple, and will work
>> better for users without JS.
> 
> I'm missing something, I'm sure.  

Yes, you are.

> How would the hidden divs get
> toggled if the user doesn't have javascript?

They wouldn't, obviously.  If I were doing something like this, I'd 
probably have the JS hide the divs in the first place, so that without 
JS, the forms would still be available.

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: Advise wanted on Ror software development and project m

2010-06-07 Thread Marnen Laibow-Koser
Ginty wrote:
> On Jun 6, 4:57�pm, Marnen Laibow-Koser  wrote:
>> repo, what do you use to host it if not Gitosis? �It's not extra baggage
>> -- it's the easiest way to host a git repo from your own server.
>>
>> Are you perchance confusing Gitosis with Gitorious?
> 
> My workflow has simply been:
> 
> Establish SSH access to my server.
> Copy the repo there, this one now becomes my master.
> Clone it from my local machine via: git clone u...@server:/path/to/
> repo.git
> Push/pull at will.
> Setup Capistrano to use the master repo.

As what user?

> Deploy at will.
> 
> I see how Gitosis or whatever is useful, maybe even required for multi-
> user setups, but for a 1-man band, like the OP, I don't think it gives
> you anything except additional setup.

OK, apparently we're not hearing each other.  Gitosis setup is simple, 
and it gives you a ridiculously easy way of managing users' keys.  Even 
for my solo freelance business, I can't imagine *not* using Gitosis. 
When you have two users -- and if you have Cap, you should have two 
users -- you need Gitosis.  Try it!


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: install acts_as_textiled

2010-06-07 Thread slindsey3000
Yes!

On Jun 5, 1:52 pm, Ugis Ozols  wrote:
> There's a workaround 
> -http://groups.google.ca/group/rubyonrails-talk/browse_thread/thread/2...
> - last post by Ahmed Mohamed.
>
> On Jun 5, 11:34 pm, slindsey3000  wrote:
>
> > I have git installed on my windows machine.
>
> > Am typing ruby script/plugin install 
> > git://github.com/defunkt/acts_as_textiled.git
>
> > In my vendor/plugins directory it shows acts_as_textiled.
>
> > However, there are no files in the folder and obviously when I run
> > rails I get  "undefined method `acts_as_textiled' "
>
> > Have tried --force to try again, and have tried http instead of git.
>
> > Any thoughts?
>
> > Thanks!
>
> > Shawn

-- 
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 do you update HABTM relationships or create.

2010-06-07 Thread Ali Akhtarzada
Formtastic indeed.

On Mon, Jun 7, 2010 at 4:21 PM, Marnen Laibow-Koser wrote:

> bramu...@gmail.com wrote:
> > I am very new to Rails and I am more or less only 6 months to 1 year
> > kid in Rails...
> >
> > I just wondering with your code.. I really dont see what is
> > "semantic_form_for " and f.buttons?? Is it view helper that you have
> > written or any plugin which overrides the default form_for construct??
> > This would be very helpful to me in writing the more maintainable
> > Rails code...
>
> He said he was using Formtastic.  That's probably where those methods
> come from.  But don't take my word for it.  Google is your friend in
> this case.
>
> 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: net/http set content-type for images

2010-06-07 Thread Kim
Thanks that did it. I am caching the image - though since it's a
webcam image that needs refreshed to stay current the cache is short
lived.


def image
@result = Net::HTTP.get_response(URI.parse('http://
link_to_image.jpg') ).body
end

index.html
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Advise wanted on Ror software development and project m

2010-06-07 Thread Ginty


On Jun 6, 4:57 pm, Marnen Laibow-Koser  wrote:
> Ginty wrote:
>
> [...]
>
> > Once you have a server though you may as well just stick your master
> > repository there. I still don't see any real need for the extra
> > baggage of Gitosis or whatever if you are dealing with a 1 or 2 man
> > team.
>
> Then, when you've got your server and aren't using Dropbox for your
> repo, what do you use to host it if not Gitosis?  It's not extra baggage
> -- it's the easiest way to host a git repo from your own server.
>
> Are you perchance confusing Gitosis with Gitorious?

My workflow has simply been:

Establish SSH access to my server.
Copy the repo there, this one now becomes my master.
Clone it from my local machine via: git clone u...@server:/path/to/
repo.git
Push/pull at will.
Setup Capistrano to use the master repo.
Deploy at will.

I see how Gitosis or whatever is useful, maybe even required for multi-
user setups, but for a 1-man band, like the OP, I don't think it gives
you anything except additional setup.

>
> 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: Can a dropdown be used to select additional form fields?

2010-06-07 Thread Bill Walton
Hi Steve,

> Steve Russo wrote:
>> For the last week and a half I've really struggled trying to do
>> something I assumed would be pretty straight forward. However I continue
>> to find road blocks regardless of the approach I take. No one on the web
>> seems to have covered this or run into this problem...

Didn't see your origiinal post.  Sorry.  This is straight forward.

>> Basically I want a drop down field to offer a certain sets of form_for
>> fields I have stored in different partials. Each partial contain
>> certains fields for the form. Based on the selection in the drop down,
>> teh approparaiet partial/fields will be displayed on the page.

Put an observe field on the select input that calls a method in your
controller that renders the desired partial.  Easiest thing to do is
put the (set of) empty div(s) in the form so you can use
page.replace_html.  If you want to get rid of the select when the
partial is displayed, put it inside the div that will have its
inner_html replaced.  You'll need to add named routes to your
UI-manipulating methods.

Some, like Marnen, will tell you not to use RJS because it puts inline
js in the page source.  Do as you like. I'm a Rails developer.  I work
primarily in Rails code, not in page source, so it matters not one bit
to me what Rails generates as long as it validates.  When I need to
write custom js, I do and I do it unobtrusively, but I use Rails
helpers whenever they'll do.  YMMV.

Best regards,
Bill

-- 
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: Can a dropdown be used to select additional form fields?

2010-06-07 Thread Steve Russo
Bill Walton wrote:
> On Mon, Jun 7, 2010 at 4:22 PM, Marnen Laibow-Koser
>  wrote:
>> Build all the forms in advance, inside hidden divs. �Then show one div
>> or another based on dropdown selection. �Very simple, and will work
>> better for users without JS.
> 
> I'm missing something, I'm sure.  How would the hidden divs get
> toggled if the user doesn't have javascript?

Bill,  I hear what you're saying. You'll need some JS to hide show the 
DIV. Unless you use RJS. I know if you're using link_to_function, you 
can use page[div].hide or page[div].show.  However, for a select box, 
your only option is to use observe_field I believe. The :function 
parameter allows you to input JS code only I believe. Don't believe RJS 
is accepted.

-- 
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: Can a dropdown be used to select additional form fields?

2010-06-07 Thread Steve Russo
Hi Marnen,
   Thanks for the advice. I had actually started off with that approach 
but thought it would be more economical to just render the desired 
partial to one div. Unfortunately, due to the headaches I mentioned in 
previous comments, I think I will give that approach another shot. 
Doesn't seem I have many other choices. I'll keep you posted...

Thanks again for your continued help Marnen!

-- 
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: Can a dropdown be used to select additional form fields?

2010-06-07 Thread Bill Walton
On Mon, Jun 7, 2010 at 4:22 PM, Marnen Laibow-Koser
 wrote:
> Build all the forms in advance, inside hidden divs.  Then show one div
> or another based on dropdown selection.  Very simple, and will work
> better for users without JS.

I'm missing something, I'm sure.  How would the hidden divs get
toggled if the user doesn't have javascript?

-- 
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: noob question about irb

2010-06-07 Thread radu puspana
when i try to log in to ruby-forums it will not let me nor create a
new account...anyi idea why?

regards,
radu

On Jun 8, 12:37 am, Marnen Laibow-Koser  wrote:
> radu puspana wrote:
> > hey guys,
>
> > can you spare some time?
>
> > i have this crazy thing with ruby.
>
> > when i enter irb and hit the return key, instead to run interactive
> > ruby the shell gives me this :
>
> > ra...@radup:~$ irb
>
> > Directory doc already exists, but it looks like it
> > isn't an RDoc directory. Because RDoc doesn't want to risk
> > destroying any of your existing files, you'll need to
> > specify a different output directory name (using the
> > --op  option).
>
> > any idea how to make irb work?
>
> This is a Ruby question, not a Rails question.  You'll want to ask on
> the Ruby list.
>
> > many thx,
> > radu
>
> 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: noob question about irb

2010-06-07 Thread Marnen Laibow-Koser
radu puspana wrote:
> hey guys,
> 
> can you spare some time?
> 
> i have this crazy thing with ruby.
> 
> when i enter irb and hit the return key, instead to run interactive
> ruby the shell gives me this :
> 
> ra...@radup:~$ irb
> 
> Directory doc already exists, but it looks like it
> isn't an RDoc directory. Because RDoc doesn't want to risk
> destroying any of your existing files, you'll need to
> specify a different output directory name (using the
> --op  option).
> 
> any idea how to make irb work?
> 

This is a Ruby question, not a Rails question.  You'll want to ask on 
the Ruby list.

> many thx,
> radu

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: Can a dropdown be used to select additional form fields?

2010-06-07 Thread Marnen Laibow-Koser
Steve Russo wrote:
> For the last week and a half I've really struggled trying to do
> something I assumed would be pretty straight forward. However I continue
> to find road blocks regardless of the approach I take. No one on the web
> seems to have covered this or run into this problem...
> 
> Basically I want a drop down field to offer a certain sets of form_for
> fields I have stored in different partials. Each partial contain
> certains fields for the form. Based on the selection in the drop down,
> teh approparaiet partial/fields will be displayed on the page.

Build all the forms in advance, inside hidden divs.  Then show one div 
or another based on dropdown selection.  Very simple, and will work 
better for users without JS.

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] noob question about irb

2010-06-07 Thread radu puspana
hey guys,

can you spare some time?

i have this crazy thing with ruby.

when i enter irb and hit the return key, instead to run interactive
ruby the shell gives me this :

ra...@radup:~$ irb

Directory doc already exists, but it looks like it
isn't an RDoc directory. Because RDoc doesn't want to risk
destroying any of your existing files, you'll need to
specify a different output directory name (using the
--op  option).

any idea how to make irb work?

many thx,
radu

-- 
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: Accessing a class's variables from an included module

2010-06-07 Thread Yanni Mac

Thanks guys for the quick responses.. looks like I will go back to the 
drawing board.  I was trying to force it in the initialize method to 
save a line of code, but creating create_from_csv_row is a much better 
solution giving the problems you guys outlined here.  Looks like 
polymorphism may solve some of my problems if I can rework my legacy db 
schema a bit.

> Regardless, I think you're "solving" your problem the wrong way -
> you're *never* going to be able to instanciate an object without a CSV
> row; is that really what you want? How will the rest of your
> application work when you just want to query the DB for
> ShirtProduct.first?

I actually included a check which I left out of the simplified code, 
which will allow regular use of initialize method if I leave out the 
row:

def initialize(attributes = nil,row=nil)
super(attributes)
unless row.blank?
  #ugly code goes here
end
end

I was messing around with this some more and I figured out I can use 
class variables to achieve what I was trying to do.  Set the class var 
in first line of the module: @@table_fields and then reset it in the 
class.  The module has access to it in the class var in the initialize 
method after this.  Although I am scrapping this design in favor of what 
was suggested.. figured I would still post what I came up with.
-- 
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] Accessing a class's variables from an included module

2010-06-07 Thread Frederick Cheung


On 7 Jun 2010, at 20:42, Yanni Mac  wrote:

> 
> 
>  def initialize(attributes = nil,row)
>super(attributes)
>.each_with_index do |field,i|
>  #NOTE: row is an array of values (csv row to array)
>  eval("self.#{field} = row[#{i}]")
>end
>  end
> end
> 

Don't use eval for this - send("#{field}=", value) will do the trick

> I dont want to have to code an initialize method for every type of
> product and I thought it would be much easier to use metaprogramming and
> just pass an array of fields to a base initialize method.  I may be way
> off here and there may be a completely different design pattern that
> would support this use case better, but this is what I originally came
> up with.  I have tried several things with attr_accessor, CONSTANTS,
> etc.. but I have not been able to get the initialize method to see
> variables I set in the class.  I am probably missing something simple as
> I don't fully understand the module's scope of access to the class...
> seems pretty straight forward vice-versa (class from module), but the
> other way around is confusing me a bit.  let me know if you got any
> ideas.  THANKS!

If you choose to go down the constant route, remember that constants are scoped 
lexically. Try something like self.class::SOME_CONSTANT

Michael's advice is also sensible - writing a create_from_csv_row method is 
probably sounder


Fred
> -- 
> 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.



Re: [Rails] Accessing a class's variables from an included module

2010-06-07 Thread Michael Pavling
On 7 June 2010 20:42, Yanni Mac  wrote:
> class ShirtProduct < ActiveRecord::Base
> end
>
> class PantsProduct < ActiveRecord::Base
> end

And have you *really* designed to have a different table for different
types of product? I can only imagine lots of pain that will be caused
by that further down the line.

I'd suggest a look at polymorphism.

-- 
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] How to add dynamic routes to routes.rb. Worked in rails2 doesn't work in rails3

2010-06-07 Thread db--
I've the following solution for this in rails2

In config/routes.rb

Page.all.each do |page|
  map.connect page.url, :controller => p.controller, :action =>
p.action
  #   get page.url + ' => ' + p.controller+'#'+p.action
end


This worked in rails2 but in rails3 this doesn't work anymore. I do
get "rake routes" display my route but app.get('/test/page') doesn't
work. I guess it has something to do with the parsing of my Page
class, as not only map.method is relevant, but also any word inside
that block.


Could somebody help?

best,

dennis

-- 
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] Accessing a class's variables from an included module

2010-06-07 Thread Michael Pavling
On 7 June 2010 20:42, Yanni Mac  wrote:
> I created a mixin module called BaseProduct.  This module has an
> initialize method in it.  I am trying to use some meta-programming to
> set variables in initialize from the class that the module is in
> included in..

There's a lot of recommendation against overloading initialize for
AR::Base classes:
http://www.google.co.uk/search?sourceid=chrome&ie=UTF-8&q=rails+overload+initialize

Regardless, I think you're "solving" your problem the wrong way -
you're *never* going to be able to instanciate an object without a CSV
row; is that really what you want? How will the rest of your
application work when you just want to query the DB for
ShirtProduct.first?

-- 
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] Accessing a class's variables from an included module

2010-06-07 Thread Yanni Mac
I created a mixin module called BaseProduct.  This module has an
initialize method in it.  I am trying to use some meta-programming to
set variables in initialize from the class that the module is in
included in.. I pass a CSV row into the initialize method and it needs
to set all the variables.  Its a bit confusing trying to explain it, but
here is what it looks like:

Note: the real world scenario is a bit more complicated using different
objects, but I simplified it here to use a "product" scenario.
-
# is pseudo-code

Module BaseProduct
  def self.included(base)
#some stuff goes here
  end

  def initialize(attributes = nil,row)
super(attributes)
.each_with_index do |field,i|
  #NOTE: row is an array of values (csv row to array)
  eval("self.#{field} = row[#{i}]")
end
  end
end

class ShirtProduct < ActiveRecord::Base
   = ["size","color","collar_type"]
  include BaseProduct
end

class PantsProduct < ActiveRecord::Base
   = ["waist","length","material"]
  include BaseProduct
end

--

I am import data from different CSVs (one for each type of product..
each having different attributes) into tables by so using this code I
want to be able to do this in rails:

pants = PantsProduct.new(nil,csv_row)
pants.save

I dont want to have to code an initialize method for every type of
product and I thought it would be much easier to use metaprogramming and
just pass an array of fields to a base initialize method.  I may be way
off here and there may be a completely different design pattern that
would support this use case better, but this is what I originally came
up with.  I have tried several things with attr_accessor, CONSTANTS,
etc.. but I have not been able to get the initialize method to see
variables I set in the class.  I am probably missing something simple as
I don't fully understand the module's scope of access to the class...
seems pretty straight forward vice-versa (class from module), but the
other way around is confusing me a bit.  let me know if you got any
ideas.  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.



Re: [Rails] Re: Visual Effect: insert new stuff, then slide open

2010-06-07 Thread Piyush Choudhary
try this, if it helps
http://wiki.github.com/madrobby/scriptaculous/combination-effects-demo

On Mon, Jun 7, 2010 at 11:43 PM, Chris Kalaboukis wrote:

> anyone?
>
> Chris Kalaboukis wrote:
> > Hi guys: Thanks for your help so far - think I've progressed pretty far
> > down the Rails front but I think I'm getting stuck, maybe you can help
> > me out:
> >
> > I've got a twitter like app where I'm trying to display new tweets as
> > they come in. This is what I'm doing right now:
> >
> >
> > Is there an easier way?
> >
> > Thanks...Chris
> --
> 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: Visual Effect: insert new stuff, then slide open

2010-06-07 Thread Chris Kalaboukis
anyone?

Chris Kalaboukis wrote:
> Hi guys: Thanks for your help so far - think I've progressed pretty far
> down the Rails front but I think I'm getting stuck, maybe you can help
> me out:
> 
> I've got a twitter like app where I'm trying to display new tweets as
> they come in. This is what I'm doing right now:
> 
> 
> Is there an easier way?
> 
> Thanks...Chris
-- 
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: help with a daft question....:-)

2010-06-07 Thread RubyonRails_newbie
* sorted *

I added @users = User.all and it returned all users

I can take it from there now...

On 7 June, 18:24, RubyonRails_newbie 
wrote:
> It is that line that it is complaining about...
>
> However my user controller must have this already as i burgled the
> code from another page that displays a list of pending friends...
>
> i'll do some more digging - thanks
>
> On 7 June, 18:06, Colin Law  wrote:
>
>
>
> > On 7 June 2010 17:45, RubyonRails_newbie  
> > wrote:
>
> > > Hello, I am hoping somwone can help with this
>
> > > Basically I have a website and I want to display a list of users
> > > currently using the site, prior to someone logging in.
>
> > > In a sense, it is a way for people to view a profile before logging
> > > in, and then they can choose whether or not to add them as a friend,
>
> > > SO - I have  a login page which contains a link to a partial:
>
> > > <%= render :partial => "user/friendlist" %>
>
> > > in the friendlist file I have the following:
>
> > > <% @users.each do |user| %>
>
> > >        <%= link_to thumbnail_tag(user), profile_for(user) %>
> > >        <%= link_to user.username, profile_for(user) %>
>
> > > <% end %>
>
> > > However, the login page cannot render with this code as it complains
> > > about a nil object: (see below)
>
> > > 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.each
>
> > > What do I need to amend or add in oder for this to work?
>
> > You have not shown us the trace so we can see which line it failed on.
> >  Have a look at that, if it is the @users.each line then this suggests
> > that you have not put anything in @users, which you should be doing in
> > the controller.  I suggest you have a look at the Rails Guide (google
> > if necessary) on debugging which will help you when you want to break
> > in and have a look at your variables.
>
> > To achieve what you want you will have to load @users with currently
> > logged in users.
>
> > 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: help with a daft question....:-)

2010-06-07 Thread RubyonRails_newbie
It is that line that it is complaining about...

However my user controller must have this already as i burgled the
code from another page that displays a list of pending friends...

i'll do some more digging - thanks

On 7 June, 18:06, Colin Law  wrote:
> On 7 June 2010 17:45, RubyonRails_newbie  wrote:
>
>
>
>
>
> > Hello, I am hoping somwone can help with this
>
> > Basically I have a website and I want to display a list of users
> > currently using the site, prior to someone logging in.
>
> > In a sense, it is a way for people to view a profile before logging
> > in, and then they can choose whether or not to add them as a friend,
>
> > SO - I have  a login page which contains a link to a partial:
>
> > <%= render :partial => "user/friendlist" %>
>
> > in the friendlist file I have the following:
>
> > <% @users.each do |user| %>
>
> >        <%= link_to thumbnail_tag(user), profile_for(user) %>
> >        <%= link_to user.username, profile_for(user) %>
>
> > <% end %>
>
> > However, the login page cannot render with this code as it complains
> > about a nil object: (see below)
>
> > 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.each
>
> > What do I need to amend or add in oder for this to work?
>
> You have not shown us the trace so we can see which line it failed on.
>  Have a look at that, if it is the @users.each line then this suggests
> that you have not put anything in @users, which you should be doing in
> the controller.  I suggest you have a look at the Rails Guide (google
> if necessary) on debugging which will help you when you want to break
> in and have a look at your variables.
>
> To achieve what you want you will have to load @users with currently
> logged in users.
>
> 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.



Re: [Rails] redirect_to issue

2010-06-07 Thread Colin Law
On 7 June 2010 17:52, Mlle  wrote:
> I'm having trouble getting redirect_to to work.
> I have a search controller  with the following code:
>
>    if params[:format].include?("map")
>      source = params[:format].split('_').second
>      redirect_to :controller => "geodatas", :action => "map", :source
> => "samples_"+source
>    else
>      #if params[:jointables].include?("images")
>      if params[:viewtable] == "images"
>        redirect_to :controller => "images", :action => "list"
>      else
>        redirect_to :controller => "samples", :action =>
> "resultslist", :id=>nil
>      end
>    end
>
> In the last else it is supposed to redirect to the resultslist action
> of the samples controller, but it is going to the show action
> instead.  This is the error that shows in the browser.
>
>  ActiveRecord::RecordNotFound in SamplesController#show
>
> Couldn't find Sample with ID=resultslist
>
>
> Why is it going to the show action??
>

Have a look in the log (log/development.log) and see if that helps

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.



Re: [Rails] help with a daft question....:-)

2010-06-07 Thread Colin Law
On 7 June 2010 17:45, RubyonRails_newbie  wrote:
> Hello, I am hoping somwone can help with this
>
> Basically I have a website and I want to display a list of users
> currently using the site, prior to someone logging in.
>
> In a sense, it is a way for people to view a profile before logging
> in, and then they can choose whether or not to add them as a friend,
>
>
> SO - I have  a login page which contains a link to a partial:
>
> <%= render :partial => "user/friendlist" %>
>
> in the friendlist file I have the following:
>
> <% @users.each do |user| %>
>
>
>        <%= link_to thumbnail_tag(user), profile_for(user) %>
>        <%= link_to user.username, profile_for(user) %>
>
> <% end %>
>
> However, the login page cannot render with this code as it complains
> about a nil object: (see below)
>
> 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.each
>
> What do I need to amend or add in oder for this to work?

You have not shown us the trace so we can see which line it failed on.
 Have a look at that, if it is the @users.each line then this suggests
that you have not put anything in @users, which you should be doing in
the controller.  I suggest you have a look at the Rails Guide (google
if necessary) on debugging which will help you when you want to break
in and have a look at your variables.

To achieve what you want you will have to load @users with currently
logged in users.

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] redirect_to issue

2010-06-07 Thread Mlle
I'm having trouble getting redirect_to to work.
I have a search controller  with the following code:

if params[:format].include?("map")
  source = params[:format].split('_').second
  redirect_to :controller => "geodatas", :action => "map", :source
=> "samples_"+source
else
  #if params[:jointables].include?("images")
  if params[:viewtable] == "images"
redirect_to :controller => "images", :action => "list"
  else
redirect_to :controller => "samples", :action =>
"resultslist", :id=>nil
  end
end

In the last else it is supposed to redirect to the resultslist action
of the samples controller, but it is going to the show action
instead.  This is the error that shows in the browser.

 ActiveRecord::RecordNotFound in SamplesController#show

Couldn't find Sample with ID=resultslist


Why is it going to the show action??

-- 
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] help with a daft question....:-)

2010-06-07 Thread RubyonRails_newbie
Hello, I am hoping somwone can help with this

Basically I have a website and I want to display a list of users
currently using the site, prior to someone logging in.

In a sense, it is a way for people to view a profile before logging
in, and then they can choose whether or not to add them as a friend,


SO - I have  a login page which contains a link to a partial:

<%= render :partial => "user/friendlist" %>

in the friendlist file I have the following:

<% @users.each do |user| %>


<%= link_to thumbnail_tag(user), profile_for(user) %>
<%= link_to user.username, profile_for(user) %>

<% end %>

However, the login page cannot render with this code as it complains
about a nil object: (see below)

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.each

What do I need to amend or add in oder for this to work?

Kind regards & thanks for reading

-- 
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: ActiveRecord.find - Association Not Found Error When Using Custom Joins

2010-06-07 Thread Ar Chron
Well, example code, yours to be exact, would help in diagnosing the 
issue...

Otherwise, it's simply 'you must have implemented something incorrectly'
-- 
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: ActiveRecord.find - Association Not Found Error When Using Custom Joins

2010-06-07 Thread Frederick Cheung


On Jun 7, 4:46 pm, neufelni  wrote:

> According to the documentation found 
> here:http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001777,
> the :joins parameter can contains "an array containing a mixture of
> both strings and named associations." That is exactly what I'm doing,
> so I'm not sure why I'm getting this error when trying to combing
> them.
>
> Any ideas why this error would occur?
>

A cursory look at the code suggests that nothing is being done to
handle the case of a mixture of strings & named associations.

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] ActiveRecord.find - Association Not Found Error When Using Custom Joins

2010-06-07 Thread neufelni
Hello,

When calling the find method on one of my models, I am joining to
several other table using the :joins parameter. Currently, the :joins
parameter is being populated with an array of several associations.
However, I need to add a custom join, but when I add a string with my
custom join to the joins array, I get the following error:

Association named ' INNER JOIN ... ' was not found; perhaps you
misspelled it?

According to the documentation found here:
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M001777,
the :joins parameter can contains "an array containing a mixture of
both strings and named associations." That is exactly what I'm doing,
so I'm not sure why I'm getting this error when trying to combing
them.

Any ideas why this error would occur?

Thanks,
neufelni

-- 
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: REE and ruby PATH problem

2010-06-07 Thread Frederick Cheung


On Jun 7, 3:43 pm, tispratik  wrote:
> ubuntu > whereis gem
> gem: /usr/bin/gem1.8 /usr/bin/gem /opt/ruby-enterprise-1.8.7-2010.01/
> bin/gem
>
> As Ivan suggested, i think its a rubygems problem. I havent installed
> rubygems in the REE. Currently it is installed only in normal ruby.
> I will install rubygems in REE and uninstall from normal ruby and then
> check. Basically keeping only REE.

The REE installer installs rubygems for you (and your whereis output
shows that)

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] Can a dropdown be used to select additional form fields?

2010-06-07 Thread Steve Russo
For the last week and a half I've really struggled trying to do
something I assumed would be pretty straight forward. However I continue
to find road blocks regardless of the approach I take. No one on the web
seems to have covered this or run into this problem...

Basically I want a drop down field to offer a certain sets of form_for
fields I have stored in different partials. Each partial contain
certains fields for the form. Based on the selection in the drop down,
teh approparaiet partial/fields will be displayed on the page.

Initially, I tried using the observe_field and an RJS file. This
approach failed because I couldn't pass the form_builder object through
the observe_field method sending to an action and then RJS file.

I then tried to use pure javascript in the observe_field method using
the :function parameter. The problem with this approach is that there
doesn't seem to be any way to pass the getElementById(field_name).value
into the ruby call within the #{}. See below...

<%#= observe_field("trial_npi_org_id", :function =>
$('section_two').innerHTML = '#{escape_javascript(render 'section_two',
:f => f, :selected_org => 1 )}'"
) %>

I was able to build a string with the correct form and then tried to use
eval() to execute, but this fails with a JS error claiming "illegal
character". I think this is the the eval() function choking on the ruby
call with #{}.

I'm somewhat new to rails but this seems like it should be doable.

If anyone can help, I would truly appreciate it.  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] Can we configure CanCan on Devise

2010-06-07 Thread Siva Kilaru
Hello guys,

This is my quick question.

Can we configure CanCan on Devise? If so, please gimme the outlines on
it.

Any reference site is much appreciated.

Thank you
Siva
-- 
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: REE and ruby PATH problem

2010-06-07 Thread tispratik
ubuntu > whereis gem
gem: /usr/bin/gem1.8 /usr/bin/gem /opt/ruby-enterprise-1.8.7-2010.01/
bin/gem

As Ivan suggested, i think its a rubygems problem. I havent installed
rubygems in the REE. Currently it is installed only in normal ruby.
I will install rubygems in REE and uninstall from normal ruby and then
check. Basically keeping only REE.

-- 
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] problems with basic Rails

2010-06-07 Thread Colin Law
On 7 June 2010 14:46, An Car  wrote:
> Hi all,
> I'm a newbie

Have a look at the rails guides at http://guides.rubyonrails.org/.
Start with Getting Started, oddly enough.  That will explain some
things you are missing and should get you going.  The ones on
ActiveRecord relationships and Debugging are also compulsory reading.

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.



Re: [Rails] problems with basic Rails

2010-06-07 Thread Hassan Schroeder
On Mon, Jun 7, 2010 at 6:46 AM, An Car  wrote:

> I did:
> 1- rails depot -d mysql
> 2- rake db:create
> 3- I've created "products" table with mysql command line editor
> 4- ruby script\generate scaffold Product
> 5- I Start webrick

Whoa, what? It appears you've tried to create a Product model but
not specified any attributes for it, so it's not surprising you'd get an
empty "new" page.

Second, after you create a new model, you need to get that info into
the database, using `rake db:migrate`.

> 6- go on localhost:3000/products and find (correctly) an empty list
> 7- I want insert a new product, click on "new" but the page is empty
> (see img attached)

> Maybe Rails can't connect with Mysql or something else...

Uh, "maybe"? You can easily determine that by either looking at your
log file, or opening a console and trying something that will need to do
a DB access.

But build a proper model and run migrations first, and see what happens.
-- 
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.



Re: [Rails] problems with basic Rails

2010-06-07 Thread Ivan Nastyukhin
not use 1.9.1
//
crash log please

Ivan Nastyukhin
dieinz...@me.com






On Jun 7, 2010, at 5:46 PM, An Car wrote:

> Hi all,
> I'm a newbie
> 
> I've installed RoR on win 7 and this is script\about
> 
> About your application's environment
> Ruby version  1.9.1 (i386-mingw32)
> RubyGems version  1.3.7
> Rack version  1.1
> Rails version 2.3.8
> Active Record version 2.3.8
> Active Resource version   2.3.8
> Action Mailer version 2.3.8
> Active Support version2.3.8
> Application root  F:/rubyProject/depot
> Environment   development
> Database adapter  mysql
> Database schema version   0
> 
> I did:
> 1- rails depot -d mysql
> 2- rake db:create
> 3- I've created "products" table with mysql command line editor
> 4- ruby script\generate scaffold Product
> 5- I Start webrick
> 6- go on localhost:3000/products and find (correctly) an empty list
> 7- I want insert a new product, click on "new" but the page is empty
> (see img attached)
> 
> and if I click on "create" ruby crashes...
> 
> Maybe Rails can't connect with Mysql or something else...
> 
> database.yml:
> 
> development:
>  adapter: mysql
>  encoding: utf8
>  reconnect: false
>  database: depot_development
>  pool: 5
>  username: root
>  password: password
>  host: localhost
> 
> # Warning: The database defined as "test" will be erased and
> # re-generated from your development database when you run "rake".
> # Do not set this db to the same as development or production.
> test:
>  adapter: mysql
>  encoding: utf8
>  reconnect: false
>  database: depot_test
>  pool: 5
>  username: root
>  password: password
>  host: localhost
> 
> production:
>  adapter: mysql
>  encoding: utf8
>  reconnect: false
>  database: depot_production
>  pool: 5
>  username: root
>  password: password
>  host: localhost
> 
> 
> Could anybody help me ??
> 
> Mny thanks
> 
> Attachments:
> http://www.ruby-forum.com/attachment/4776/emptyForm.jpg
> 
> -- 
> 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] problems with basic Rails

2010-06-07 Thread An Car
Hi all,
I'm a newbie

I've installed RoR on win 7 and this is script\about

About your application's environment
Ruby version  1.9.1 (i386-mingw32)
RubyGems version  1.3.7
Rack version  1.1
Rails version 2.3.8
Active Record version 2.3.8
Active Resource version   2.3.8
Action Mailer version 2.3.8
Active Support version2.3.8
Application root  F:/rubyProject/depot
Environment   development
Database adapter  mysql
Database schema version   0

I did:
1- rails depot -d mysql
2- rake db:create
3- I've created "products" table with mysql command line editor
4- ruby script\generate scaffold Product
5- I Start webrick
6- go on localhost:3000/products and find (correctly) an empty list
7- I want insert a new product, click on "new" but the page is empty
(see img attached)

and if I click on "create" ruby crashes...

Maybe Rails can't connect with Mysql or something else...

database.yml:

development:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: depot_development
  pool: 5
  username: root
  password: password
  host: localhost

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: depot_test
  pool: 5
  username: root
  password: password
  host: localhost

production:
  adapter: mysql
  encoding: utf8
  reconnect: false
  database: depot_production
  pool: 5
  username: root
  password: password
  host: localhost


Could anybody help me ??

Mny thanks

Attachments:
http://www.ruby-forum.com/attachment/4776/emptyForm.jpg

-- 
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: rake gems:freeze GEM=pdf-writer not working on MAC

2010-06-07 Thread Tushar Gandhi
Hi,
I have installed rubygems-update 1.3.6. Still the issue has not 
resolved.

Any other way.

Thanks,
Tushar
-- 
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 with database still sqlite3 and i want mysql

2010-06-07 Thread Fidel Viegas
On 6/6/10, gezope  wrote:
> Your advice is fine; the 1,2,3,4 steps are okay (I am also new in
> Linux, so i suggest 4. 'cd rubygems' you mean go to the new directory,
> here it was 'cd rubygems-1.3.7' , let me know if I misunderstand it
> please:))
>

Yes, this is what I meant.

> After it: 5. ruby setup.rb says:
>
> ERROR: While executing gem ... (Errno::EACCES)
> Permission denied: ~ /usr/local/lib/site_ruby/1.8/geuntlet_rubygems.rb
>
> I tried chmod and sudo chmod 644 and then this location, but it says:
> cannot access (here the filename).
>
> After it I tried to give the path, but i think gem is not on my system
> yet, so it is kinda useless, but I tried, maybe...
> (from here: https://help.ubuntu.com/community/RubyOnRails )
> I tried this: export PATH=/var/lib/gems/1.8/bin:$PATH
> After it still neither chmod or setup.rb runs.
>
> I tried it 2 more time, once only from Synaptic :D, and then the same
> way what u suggested (of course first delete every gem for gem list,
> than remove gem, then remove ruby, than restart the procedure).
>
> I also tried irb, than setup.rb, it says undefined local variable,
> from the directory where it should be.
>
> Finally I stopped here, in the 5th point, please help me go on! (It is
> important for me, to get involved this Ubuntu community - without
> Rails it seems hopeless. :O)
>

you need to do in step 5 the following:

Don't need to chmod the file. The permission denied meant that you
need to be root to have access to the path described.

Try this in step 5)

sudo ruby setup.rb

Try that and report back.

All the best,

Fidel.

-- 
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: rake gems:freeze GEM=pdf-writer not working on MAC

2010-06-07 Thread Tushar Gandhi
Hi,
I just done the gem list. My gem list shows I have 
"rubygems-update(1.3.7)".
How can I install rubygems version of 1.3.6?

Thanks,
Tushar

-- 
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] logging bestpractice in production

2010-06-07 Thread deepak
hi,
In production i wanted to reduce the loglevel, but when i set the
log_level to :warn, rails stops logging the request, params.
completion time etc.

The code below works, but had some questions:
1) is it ok to dup the logger object
2) i am using BufferedLogger, can the logs be shuffled
eg. i have two processes, P1 and P2

and P1 logs:
hello i am P1
the uptime is 1000

and P2 logs;
hello i am P2
the uptime is 250

and the actual log is:
hello i am P1
hello i am P2
the uptime is 1000
the uptime is 250

3) i am using passenger - will it make  a difference in (2).
Does it make a difference to logging if i am using mongrel, jruby or
passenger.

Logging config:

# See everything in the log (default is :info)
# But this also stops logging of the request by rails
config.log_level = :warn

config.logger =
ActiveSupport::BufferedLogger.new(File.join(RAILS_ROOT,
"log","{RAILS_ENV}.log"))
config.logger.level = ActiveSupport::BufferedLogger::WARN

# is dup'ing the logger object correct/bestpractice
# will the logs be in order or can they be shuffled - i am using
passenger - will it make a difference?
config.action_controller.logger = config.logger.dup
config.action_controller.logger.level =
ActiveSupport::BufferedLogger::INFO

-- 
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: Unable to set expiry date on cookies

2010-06-07 Thread Fernando Perez
"So stupid! I just noticed that in FF the option "Keep until: I close 
Firefox" was set, I must have done that inadvertently.

Sorry for my silly problem.
-- 
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: rake gems:freeze GEM=pdf-writer not working on MAC

2010-06-07 Thread Matt Jones


On Jun 7, 1:08 am, Tushar Gandhi  wrote:
> Hi,
> If that is the probelm then the command should also not work on windows.
> But it is working on windows. What is the reason?

I suspect that you've got different versions of Rubygems on the two
machines.

1.3.6 has the 2-arg version:
http://rubygems.rubyforge.org/svn/tags/REL_1_3_6/lib/rubygems/commands/unpack_command.rb

While 1.3.7 has the 1-arg version:
http://rubygems.rubyforge.org/svn/tags/REL_1_3_7/lib/rubygems/commands/unpack_command.rb

--Matt Jones

-- 
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: Unable to set expiry date on cookies

2010-06-07 Thread Fernando Perez
Ok my bad. I tested in Safari and it works perfectly, so there is 
something blocking in Firefox 3.6, but the expiry date setting works 
with other sites, so I don't understand what's happening.

Is there some edge case scenario I'm missing here? Should all options of 
the cookie be set?
-- 
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: Unable to set expiry date on cookies

2010-06-07 Thread Fernando Perez
Hi Peter,

I just checked and my browser is not in private mode. In the response I 
can see that a header is set-cookie with a date forward in time, so 
something strange is happening 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.



Re: [Rails] Unable to set expiry date on cookies

2010-06-07 Thread Peter De Berdt


On 07 Jun 2010, at 12:12, Fernando Perez wrote:


cookies[:user_info] = {:value => "whatever", :expires =>
30.days.from_now }

When I check in the browser, the cookie will expire "at end of  
session"

Oo What's happening? How to set the cookie's date then?


The code looks fine. Are you sure you haven't set your browser to  
"Private Browsing"? Because that would result in all cookies expiring  
at the end of the session.



Best regards

Peter De Berdt

--
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] Unable to set expiry date on cookies

2010-06-07 Thread Fernando Perez
cookies[:user_info] = {:value => "whatever", :expires =>
30.days.from_now }

When I check in the browser, the cookie will expire "at end of session"
Oo What's happening? How to set the cookie's date then?


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] contacts gem to save imported contacts

2010-06-07 Thread swetha
Hi,

I am working on an application ,where user can login to their gmail/
yahoo/hotmail to grab contacts from them.
I am done with getting them from respective accounts but i need help
with saving them to my application.

I am using contacts gem ,and got login and i able view the list of my
contacts ,but i am unable to save them to myapp.

-- 
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: mongrel / webrick process not shutting down properly in dev env. after ^C

2010-06-07 Thread Michael Nissim
pixelhandler wrote:
> FYI - I found a way to stop the process...
> 
> http://railstips.org/2007/2/12/oops-i-did-it-again
> 
> comand line... (shows your process)
> ps aux | grep script/server
> sudo kill -9  (kill your process X is the PID)


Thank bro, that helps a lot! Got it working again for me.
-- 
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: undefined method `tab' for radiant

2010-06-07 Thread Rich
Hi Marnen,

Apologies for posting here, I realised just after hitting send that
this wasn't the specific radiant group to be posting to, oops!

Kind Regards
Rich

On Jun 4, 9:27 pm, Marnen Laibow-Koser  wrote:
> Smit Shah wrote:
> > Hi all...
>
> > I am new to radiant cms. I have tried to install blog and liveblog
> > extensions. But in both cases I got the following error.
>
> > rake aborted!
> > undefined method `tab' for #
>
> > and
>
> > rake aborted!
> > undefined method `tab' for #
>
> > Any idea? I am using radiant 0.8.1
>
> This is a Radiant issue, not a general Rails issue.  You'll get better
> help in the Radiant support forums.
>
>
>
> > Thanks
>
> 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:

2010-06-07 Thread Tom Mac
Hi
   Finally I solved like

  Add 


And may I conclude that there is no helper which gives exact raw html 
like  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]

2010-06-07 Thread Colin Law
On 4 June 2010 05:40, Tom Mac  wrote:
> Hi
>   I would like to construct a button like
> Add 
>
> And I used the helper button_to_remote for this like
>
> <%= button_to_remote("Add",
>        { :url => some_url(@id),
>    :condition => "check_valid()",
>                :with=> "'ids='+user_ids"},
>    {:class => "form-button2 fixed3"}
>        ) %>
>
>       I get the functionality correctly But it produces html like
>
>      So
> ignoring css style
>
>   Please tell me which helper to use to get html like    type="button"...

You can always just put the raw html in yourself.

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:

2010-06-07 Thread pepe
I don't think there is a method you'll be able to use to generate a
 tag. There seem to be some compatibility issues with that
tag. I guess you have your reasons to be using  instead of
. In any case, since the call to button_to_remote
will just generate a string that will be passed back to the browser as
html maybe you can just hack something with a regex and manipulate the
result of button_to_remote to replace the initial ' wrote:
> Hi
>    You are right. But still the problem. Please help if possible
>
> Tom
> --
> 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: running passenger + nginx

2010-06-07 Thread Fernando Perez
Gordon Yeong wrote:
> i think i found something.
> Just send a SIGHUP signal to the nginx process via kill.
> Seems to work well.
>  Anyone got a better idea? :)
> 
> thanks

Yep, use: $ kill -HUP 
-- 
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] authenticity_token shows up in the url when page reloads

2010-06-07 Thread Peter De Berdt


On 07 Jun 2010, at 06:37, Stephen Kilbourn wrote:

I'm pretty new to Ruby On Rails (and somewhat self-taught), so bear  
with
me if I'm asking something stupid. So whenever I push my download  
button

(which just uses send_file, if that's any help) it reloads the page,
without downloading, and it puts the authenticity_token in the url.  
This

all the button is:
<% form_remote_tag :url => { :action => 'download'} do %>
 <%= submit_tag "Download" %>
<% end %>

Basically, it's just not working at all, and I would appreciate any  
sort

of help with the issue. Thanks in advance.


Downloading a file is a "full page refresh" (although the page won't  
actually refresh). You shouldn't use an AJAX function (whether that's  
a link or a form) to send a file to the client. Just serve it up with  
the right content type as a normal request and you'll be fine.



Best regards

Peter De Berdt

--
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: REE and ruby PATH problem

2010-06-07 Thread Sergey Varaksin
maybe `sudo echo $PATH`

On Jun 7, 2:16 pm, tispratik  wrote:
> Also notice that the gem environment does not reflect the REE version
> of Ruby,
>
> RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux]

-- 
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: REE and ruby PATH problem

2010-06-07 Thread firman syah
sudo /opt/ruby-enterprise-1.8.7-2010.01/bin/bluepill

On Mon, Jun 7, 2010 at 1:56 PM, tispratik  wrote:

> Thanks Ivan, but it still dosent work :(
>
> ubuntu > sudo bluepill status
> sudo: bluepill: command not found
>
> -Pratik
>
> On Jun 7, 1:24 am, Ivan Nastyukhin  wrote:
> > sudo ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/ruby /usr/bin/ruby
> > sudo ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/gem /usr/bin/gem
> > sudo ln -s /opt/ruby-enterprise-1.8.7-2010.01/bin/rake /usr/bin/rake
> >
> > Ivan Nastyukhin
> > dieinz...@me.com
> >
> > On Jun 7, 2010, at 10:19 AM, tispratik wrote:
> >
> >
> >
> > > I have ruby normal edition installed in /usr/bin
> > > REE in /opt/ruby-enterprise-1.8.7-2010.01/bin
> > > I have all my application gems installed in /opt/ruby-
> > > enterprise-1.8.7-2010.01/bin
> > > but still when i run any gem related command, say "sudo bluepill
> > > status", it looks for the executable in normal ruby edition instead of
> > > REE
> >
> > > Any ideas?
> >
> > > ubuntu  > echo $PATH
> > > /opt/ruby-enterprise-1.8.7-2010.01/bin
> > > /usr/local/sphinx/bin
> > > /usr/local/sbin
> > > /usr/local/bin
> > > /usr/sbin
> > > /usr/bin
> > > /sbin
> > > /bin
> >
> > > ubuntu > bluepill
> > > You must run bluepill as root.
> >
> > > ubuntu > sudo bluepill status
> > > sudo: bluepill: command not found
> >
> > > ubuntu > which bluepill
> > > bluepill is /opt/ruby-enterprise-1.8.7-2010.01/bin/bluepill
> >
> > > ubuntu > whereis bluepill
> > > bluepill: /opt/ruby-enterprise-1.8.7-2010.01/bin/bluepill
> >
> > > ubuntu > ruby -v
> > > ruby 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux], MBARI 0x6770,
> > > Ruby Enterprise Edition 2010.01
> >
> > > ubuntu > rails -v
> > > Rails 2.3.5
> >
> > > ubuntu > gem -v
> > > 1.3.5
> >
> > > ubuntu > gem list
> > > actionmailer (2.3.5)
> > > actionpack (2.3.5)
> > > activerecord (2.3.5)
> > > activeresource (2.3.5)
> > > activesupport (2.3.5)
> > > blankslate (2.1.2.3)
> > > bluepill (0.0.38)
> > > daemons (1.0.10)
> > > eventmachine (0.12.10)
> > > fastthread (1.0.7)
> > > mysql (2.8.1)
> > > passenger (2.2.14)
> > > rack (1.0.1)
> > > rails (2.3.5)
> > > rake (0.8.7)
> > > state_machine (0.9.2)
> > > thin (1.2.7)
> >
> > > ubuntu > /usr/bin/gem list
> > > actionmailer (2.3.5)
> > > actionpack (2.3.5)
> > > activerecord (2.3.5)
> > > activeresource (2.3.5)
> > > activesupport (2.3.5)
> > > rubygems-update (1.3.7)
> > > rack (1.0.1)
> > > rails (2.3.5)
> > > rake (0.8.7)
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Ruby on Rails: Talk" group.> To post to this group, send email
> torubyonrails-t...@googlegroups.com.> To unsubscribe from this group, send
> email 
> torubyonrails-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.
>
>

-- 
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: REE and ruby PATH problem

2010-06-07 Thread Sav
try check
sudo echo $PATH
sudo which bluepill

On Jun 7, 1:19 pm, tispratik  wrote:
> I have ruby normal edition installed in /usr/bin
> REE in /opt/ruby-enterprise-1.8.7-2010.01/bin
> I have all my application gems installed in /opt/ruby-
> enterprise-1.8.7-2010.01/bin
> but still when i run any gem related command, say "sudo bluepill
> status", it looks for the executable in normal ruby edition instead of
> REE
>
> Any ideas?
>
> ubuntu  > echo $PATH
> /opt/ruby-enterprise-1.8.7-2010.01/bin
> /usr/local/sphinx/bin
> /usr/local/sbin
> /usr/local/bin
> /usr/sbin
> /usr/bin
> /sbin
> /bin
>
> ubuntu > bluepill
> You must run bluepill as root.
>
> ubuntu > sudo bluepill status
> sudo: bluepill: command not found
>
> ubuntu > which bluepill
> bluepill is /opt/ruby-enterprise-1.8.7-2010.01/bin/bluepill
>
> ubuntu > whereis bluepill
> bluepill: /opt/ruby-enterprise-1.8.7-2010.01/bin/bluepill
>
> ubuntu > ruby -v
> ruby 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux], MBARI 0x6770,
> Ruby Enterprise Edition 2010.01
>
> ubuntu > rails -v
> Rails 2.3.5
>
> ubuntu > gem -v
> 1.3.5
>
> ubuntu > gem list
> actionmailer (2.3.5)
> actionpack (2.3.5)
> activerecord (2.3.5)
> activeresource (2.3.5)
> activesupport (2.3.5)
> blankslate (2.1.2.3)
> bluepill (0.0.38)
> daemons (1.0.10)
> eventmachine (0.12.10)
> fastthread (1.0.7)
> mysql (2.8.1)
> passenger (2.2.14)
> rack (1.0.1)
> rails (2.3.5)
> rake (0.8.7)
> state_machine (0.9.2)
> thin (1.2.7)
>
> ubuntu > /usr/bin/gem list
> actionmailer (2.3.5)
> actionpack (2.3.5)
> activerecord (2.3.5)
> activeresource (2.3.5)
> activesupport (2.3.5)
> rubygems-update (1.3.7)
> rack (1.0.1)
> rails (2.3.5)
> rake (0.8.7)

-- 
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] How to test login action in a controller?

2010-06-07 Thread 蕲春人
*My login page has a login form with three fields:login,password,and  image
verification code,now how to test it?*

require File.dirname(__FILE__) + "/../spec_helper"
#
http://www.kirkbushell.com/articles/testing-using-rspec-part-2-the-controller
# http://blog.enjoyrails.com/2008/02/18/rspec-basic/
#
http://rails.anyware-technologies.com.br/2009/04/21/tdd-on-rails-4-rspec-authlogic-factory_girl-and-resource_controller/

# http://matthewkwilliams.com/index.php/tag/rspec/

describe AdminController do
  integrate_views

  before(:each) do
@params = {:login => 'username', :pass => 'password', :code_image =>
"1234"}
  end

  it "should redirect after input login and pass" do
session.should_receive(:[]).with(:code).and_return("1234")  # this
does'nt work!!!
#session.stub!(:[]).with(:code).and_return "1234"
Admin.should_receive(:authenticate).with(params[:login],
params[:pass]).and_return(true)
post '/', @params
response.should be_redirect
  end

end

错误提示是:
Spec::Mocks::MockExpectationError in 'AdminController should redirect after
input login and pass'
# received :[] with unexpected
arguments
  expected: (:code)
   got: ("flash")
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/flash.rb:157:in
`flash_without_components'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/components.rb:105:in
`flash'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/flash.rb:167:in
`assign_shortcuts'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/base.rb:523:in
`process_without_filters'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/filters.rb:569:in
`process_without_session_management_support'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/session_management.rb:130:in
`process_without_test'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/test_process.rb:16:in
`process'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/test_process.rb:394:in
`process'
/home/qichunren/gems/actionpack-2.1.0/lib/action_controller/test_process.rb:365:in
`post'
./spec/controllers/admin_controller_test.rb:31:

Finished in 0.023053 seconds

-- 
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: net/http set content-type for images

2010-06-07 Thread Frederick Cheung


On Jun 7, 7:05 am, Kim  wrote:
> Really? Do you really think there isn't a reason why I am not just
> using an image_tag? Really?
>
Seems like a legitimate question to me.

> The image is protected and I have been given access to pull it from my
> web server to use in my app.
>
> Looking for help in answering my original post please. Thanks.
>

All an image is is a stream of bytes, which you have already got.
Furthermore the image is fetched by a separate request. If you really
need to go down this route you should probably craft the  tag to
point at a particular controller/action in your app and from that
action make your http request and return the bytes you get. You might
also want to cache the image on your server.

Or perhaps some rewrite rules to proxy those requests to the origin
server might make more sense

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 embed html to other site

2010-06-07 Thread Amar Daxini
Yudi Soesanto wrote:
> Hi amar,
> 
> I tried to click on your link  http://railstech.com/?p=30  and I got
> this error "You don't have permission to access / on this server"
> 
> Thanks for you help.
> Yudi

Its temporarily down
You can just use jquery load function
and insert into div
like
$("#some_div_id").load("URL")
Try this out
-- 
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: REE and ruby PATH problem

2010-06-07 Thread Frederick Cheung


On Jun 7, 7:19 am, tispratik  wrote:
> I have ruby normal edition installed in /usr/bin
> REE in /opt/ruby-enterprise-1.8.7-2010.01/bin
> I have all my application gems installed in /opt/ruby-
> enterprise-1.8.7-2010.01/bin
> but still when i run any gem related command, say "sudo bluepill
> status", it looks for the executable in normal ruby edition instead of
> REE
>
> Any ideas?
>
sudo will set up its own environment (including its own PATH). You
should be able to set things up so that it includes /opt/ruby-
enterprise-1.8.7-2010.01/bin  though

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: Model validation giving problem

2010-06-07 Thread kannav rajeev
Try this in yours model


Validate :password_confirmation


def password_confirmation
--
--
-Your Code
--
--
end

On Mon, Jun 7, 2010 at 12:48 PM, Tushar Gandhi  wrote:

> Hi Rajeev,
> I just added the model validations for understanding.
>
> Whatever model validation you have added are same in my model.
>
> Thanks,
> Tushar
> --
> 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.
>
>


-- 
Thanks:
Rajeev sharma

-- 
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: Model validation giving problem

2010-06-07 Thread Tushar Gandhi
Hi Rajeev,
I just added the model validations for understanding.

Whatever model validation you have added are same in my model.

Thanks,
Tushar
-- 
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: REE and ruby PATH problem

2010-06-07 Thread tispratik
Also notice that the gem environment does not reflect the REE version
of Ruby,

RUBY VERSION: 1.8.7 (2009-12-24 patchlevel 248) [x86_64-linux]

-- 
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] Model validation giving problem

2010-06-07 Thread kannav rajeev
Try Some thing like this On updating Yours model Code is validating presence
of confirm_password Which should not be i think.
validate_uniqueness_of :login
validate_presence_of :password, :name,
validate_confirmation_of:confirm_password.


On Mon, Jun 7, 2010 at 12:19 PM, Tushar Gandhi  wrote:

> Hi,
> I have a member registration form which takes a "Name", "Login",
> "Password", "Confirm Password" and  "Location". In the user model I have
> added the validation
> validate_uniqueness_of :login, validate_presence_of :password, :name,
> :confirm_password.
>
> When the member tries to register every thing working fine. I am using
> same form for user to edit his information. When the user come to edit
> his information we are not allowing the user to edit the password so
> that we are hiding those fields.
> But whenever user adds some invalid data suppose he hasn't added the
> "name" then the error is shown "Name should not be blank" but with that
> it also shows that "Password should not be blank". I have checked the
> post data don't have the password and confirm password parameter. My
> controller code is like this:-
>
> "@member = User.find(params[:user_id])
>  @member.update_attributes(params[:user]) "
>  Can anyone have any idea how to solve this?
>
> Thanks
> Tushar
> --
> 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.
>
>


-- 
Thanks:
Rajeev sharma

-- 
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.