rubyonrailsin

A Ruby and Rails talk

Friday, March 26, 2010

[Rails] Rake argument error

by rubyonrailsin 0 comments
Hi,

I'm having a problem loading a sample data with simple rake command.
rake db:fixtures:load

When I run the above command,I get the following error

$rake db:fixtures:load
(in /home/raghu/www/photos)
rake aborted!
a YAML error occurred parsing
/home/raghu/www/photos/test/fixtures/photos.yml. Please note that YAML
must be consistently indented using spaces. Tabs are not allowed. Please
have a look at http://www.yaml.org/faq.html
The exact error was:
ArgumentError: syntax error on line 14, col 11: ` filename:
train.jpg'

(See full trace by running task with --trace)

Here is the file that can be useful

# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

one:
filename: MyString
thumbnail: MyString
description: MyString

two:
filename: MyString
thumbnail: MyString
description: MyString

photo_1:
id:1
filename: train.jpg
thumbnail: train_t.jpg
description: My ride to work

photo_2:
id: 2
filename: lighthouse.jpg
thumbnail: lighthouse_t.jpg
description: I take dates here all the time

photo_3:
id: 3
filename: gargoyle.jpg
thumbnail: gargoyle_t.jpg
description: My paper weight

photo_4:
id: 4
filename: cat.jpg
thumbnail: cat_t.jpg
description: My pet
photo_5:
id: 5
filename: cappucino.jpg
thumbnail: cappucino_t.jpg
description: Life Juice

photo_6:
id: 6
filename: building.jpg
thumbnail: building_t.jpg
description: My office
photo_7:
id: 7
filename: bridge.jpg
thumbnail: bridge_t.jpg
description: Place I'd like to visit

Any idea of what might went wrong?

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

Read More…

Re: [Rails] Re: Re: Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
PS. Don't know if the loading of tooltip should be moved down below jQuery or Prototype – it depends on what it relies on.

/Lasse

2010/3/26 Lasse Bunk <lassebunk@gmail.com>
Ok, what I didn't think of was that the jQuery noConflict call should of course occur *before* loading Prototype, like this:


<head>
 <%= javascript_include_tag "tooltip" %>
 <%= javascript_include_tag 'jquery' %>
 <script type="text/javascript" charset="utf-8">
   jQuery.noConflict();
 </script>

 <%= javascript_include_tag "jquery.prettyPhoto" %>
 <%= javascript_include_tag 'application' %>
 <%= javascript_include_tag 'prototype' %>
 <%= javascript_include_tag 'scriptaculous' %>
</head>

<body>
<script type="text/javascript" charset="utf-8">
  jQuery(document).ready(
    function() {
      jQuery("a[rel^='prettyPhoto']").prettyPhoto();
    });
</script>

Would this do the trick?


/Lasse

2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>
Lasse Bunk wrote:
> Ok – just as a test, does it work if you delete these lines?
>
>   jQuery.noConflict();
>   jQuery(document).ready(
> function() {
>     jQuery("a[rel^='prettyPhoto']").prettyPhoto();
>   });
>
> /Lasse
>
>
> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>

Yes, prototype does work, once I remove those lines...but of course
jquery doesn't.

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

Re: [Rails] Re: Re: Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
Ok, what I didn't think of was that the jQuery noConflict call should of course occur *before* loading Prototype, like this:

<head>
 <%= javascript_include_tag "tooltip" %>
 <%= javascript_include_tag 'jquery' %>
 <script type="text/javascript" charset="utf-8">
   jQuery.noConflict();
 </script>
 <%= javascript_include_tag "jquery.prettyPhoto" %>
 <%= javascript_include_tag 'application' %>
 <%= javascript_include_tag 'prototype' %>
 <%= javascript_include_tag 'scriptaculous' %>
</head>

<body>
<script type="text/javascript" charset="utf-8">
  jQuery(document).ready(
    function() {
      jQuery("a[rel^='prettyPhoto']").prettyPhoto();
    });
</script>

Would this do the trick?

/Lasse

2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>
Lasse Bunk wrote:
> Ok – just as a test, does it work if you delete these lines?
>
>   jQuery.noConflict();
>   jQuery(document).ready(
> function() {
>     jQuery("a[rel^='prettyPhoto']").prettyPhoto();
>   });
>
> /Lasse
>
>
> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>

Yes, prototype does work, once I remove those lines...but of course
jquery doesn't.

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

Re: [Rails] grouping and acts_as_tree

by rubyonrailsin 0 comments
thx!


On Fri, Mar 26, 2010 at 3:06 PM, Lasse Bunk <lassebunk@gmail.com> wrote:
You can do it like this:

# this array is just my representation of your data
paths = [["Root", "child A", "child A1"],

         ["Root", "child A"],
         ["Root", "child B", "child B999", "child C245"],
         ["Root", "child D", "child B41"],
         ["Root", "child A", "child Axyz"]]

# you can do the grouping like this
groups = paths.group_by{ |p| p[1] }

puts groups.inspect # this is a hash

/Lasse

2010/3/26 tom <tomabroad@gmail.com>

hi & thx 4 ur time:



x = find.almost_all
<p>
<% for y in @x.ancestors.reverse %>
  <%= link_to h(y.title), y  %> &gt;
<% end %>
</p>

results in:


Root > child A > child A1
Root > child A >
Root > child B > child B999 > child C245
Root > child D > child B41
Root > child A > child Axyz
....
....
..

how can i group the list above lets say by the second level, eg like this:

CHILD A
Root > child A > child A1
Root > child A >
Root > child A > child Axyz

CHILD B
Root > child B > child B999 > child C245

CHILD D
Root > child D > child B41


or even by length after grouping by title (CHILD A):
Root > child A >
Root > child A > child A1
Root > child A > child Axyz




 



On Fri, Mar 26, 2010 at 1:37 PM, Lasse Bunk <lassebunk@gmail.com> wrote:
Tom,

Maybe it's just me but I don't quite understand... Could you explain what you're trying to achieve?

/Lasse

2010/3/24 tom <tomabroad@gmail.com>
hi,

im using acts_as_tree and im not sure on how to group find-result.

x = find.almost_all

<p>
<% for y in @x.ancestors.reverse %>
  <%= link_to h(y.title), page  %> &gt;
<% end %>
</p>

gives me a nice "breadcrum". but how is it possible to group the list lets say by the 1level or second level?

thx

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

[Rails] Re: How to read a xml file?

by rubyonrailsin 0 comments
There are mistakes in the first xml source, here is the good source:

> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <fichas>
> <ficha>
> <first>Gabriel</first>
> <last>Molina</last>
> <dirs>Alfredo Vargas #36</dirs>
> </ficha>
> <ficha>
> <first>Jorge</first>
> <last>Mendoza</last>
> <dirs>Alguna de por ahi #12</dirs>
> </ficha>
> </fichas>
> -------------------------------------------------------

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

Read More…

[Rails] Ruby on Rails job opportunities

by rubyonrailsin 0 comments
I am an IT recruiter with TEKsystems. I'm working with a client here in
New Orleans that is looking to bring on several entry level Ruby on
Rails developers. I'm looking for anyone that is a Ruby novice all the
way up to 5 years of experience. It's a really great company and they
are willing to teach and mentor whoever they bring on board in Ruby. If
anyone is interested or knows anyone that is interested, please give me
a call at (504) 218-2645 or email me at sbennett@teksystems.com.

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

Read More…

[Rails] How to read a xml file?

by rubyonrailsin 0 comments
How to read a xml file?

I have this XML source:
-------------------------------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fichas>
<ficha>
<nombre>Gabriel</nombre>
<apellido>Molina</apellido>
<direccion>Alfredo Vargas #36</direccion>
</ficha>
<ficha>
<nombre>Jorge</nombre>
<apellido>Mendoza</apellido>
<direccion>Alguna de por ahi #12</direccion>
</ficha>
</fichas>
-------------------------------------------------------

And I have this RoR source:
-------------------------------------------------------
require "rexml/document"
include REXML
doc = Document.new File.new("xml_info.xml")

first_name = Array.new
last_name = Array.new
address = Array.new
n = 0

doc.elements.each("a/b/first") { |name|
first_name << name.text.to_s
n += 1
}

doc.elements.each("a/b/last") { |name|
last_name << name.text.to_s
}

doc.elements.each("a/b/dirs") { |dir|
address << dir.text.to_s
}

0.upto(n-1) do |i|
puts first_name[i]
puts last_name[i]
puts address[i]
end
-------------------------------------------------------

And it works, but when I work with this xml file, it doesn't show
anything.

My new XML file:
-------------------------------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<n1:Message xmlns:n1="urn:ActionWebService"
env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<name xsi:type="xsd:string">Jorge</name>
<last xsi:type="xsd:string">Mendoza</ape>
</n1:Message>
</env:Body>
</env:Envelope>
-------------------------------------------------------

My new RoR file:
-------------------------------------------------------
require "rexml/document"
include REXML

def test

doc = Document.new File.new("xml_info.xml")

first_name = Array.new
last_name = Array.new

doc.elements.each("env:Envelope/env:Body/n1/name") { |name|
first_name << name.text.to_s
}

doc.elements.each("env:Envelope/env:Body/n1/last") { |name|
last_name << name.text.to_s
}

# This function must return the message "Hello Jorge Mendoza"
"Hello " + first_name[0] + " " + last_name[0]

end # test
-------------------------------------------------------

The last xml and ruby source are of a web service.

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

Read More…

[spree-user] Capture on Ship or Batch Process CC Question

by rubyonrailsin 0 comments
I have a client who sells strange objects d'art and has very imprecise
inventory control--which isn't ever going to change--and presents
problems for web orders of unique items that may have sold out in the
physical store.

I would like to either hold off processing orders until the staff
checks them against stock at the end of the day or not send to
authorize.net until the order is shipped.

Any suggestions on the best way to go about this?

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

[Rails] Re: Re: Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
Lasse Bunk wrote:
> Ok – just as a test, does it work if you delete these lines?
>
> jQuery.noConflict();
> jQuery(document).ready(
> function() {
> jQuery("a[rel^='prettyPhoto']").prettyPhoto();
> });
>
> /Lasse
>
>
> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>

Yes, prototype does work, once I remove those lines...but of course
jquery doesn't.

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

Read More…

[spree-user] Re: Spree & Passenger

by rubyonrailsin 0 comments
Ok so this isn't working as well as I wrote. I'm still having issues.
It was working before but now it's not.

I need a guide to get Passenger and Spree working well... Help!
Anyone!

Thanks!

On Mar 21, 1:01 am, Marc Lipovsky <marclipov...@gmail.com> wrote:
> Actually I figured out a better way. Since everytime you hit restart
> in the passenger prefpane (on a mac), it resets the vhost.conf files
> back to the defaults that the prefpane uses, it was changing the
> custom edits I was making. So in the httpd.conf file after this:
>
> <IfModule passenger_module>
>   NameVirtualHost *:80
>   <VirtualHost *:80>
>     ServerName _default_
>   </VirtualHost>
>   Include /private/etc/apache2/passenger_pane_vhosts/*.conf
> </IfModule>
>
> I added my custom vhost, this:
>
> <VirtualHost *:80>
>  ServerName ho.detail
>  DocumentRoot "/Users/***/Sites/Rails/eaton/public"
>  # RackEnv development
>  RailsEnv development
>  PassengerPoolIdleTime 0
>  <Directory "/Users/***/Sites/Rails/eaton/public">
>    Order allow,deny
>    Allow from all
>  </Directory>  PassengerPoolIdleTime 0
> </VirtualHost>
>
> And it worked perfectly.
>
> Thanks for all your help!
>
> Marc
>
> On Mar 20, 6:17 pm, Ryan Michael <keri...@gmail.com> wrote:
>
> > I use RailsEnv and it works for me, just point it at your public
> > folder
>
> > On Mar 20, 8:45 am, Chris <r3ap3r2...@gmail.com> wrote:
>
> > > You need to edit /etc/apache2/passenger_pane_vhosts/your_vhost.conf manually.
> > > The passenger pref pane only adds "RailsEnv development" to the server
> > > config.  You also need "RackEnv development" (or production depending
> > > on which mode you are running in).
>
> > > Actually I may have it reversed, I can't remember for sure which one
> > > is added by the pref pane.  Basically, whichever one you see when you
> > > edit the file add the other and restart apache.
>
> > > -Chris
>
> > > On Sat, Mar 20, 2010 at 6:06 PM, Marc Lipovsky <marclipov...@gmail.com> wrote:
> > > > I haven't been able to find anything on this really. I'm running
> > > > passenger on my Mac and on my DreamHost domain. I'm using the
> > > > Passenger PrefPane on my Mac and I added the Spree application like I
> > > > did with the rest of the apps but it doesn't work.
>
> > > > Any ideas? Thanks!
>
> > > > --
> > > > You received this message because you are subscribed to the Google Groups "Spree" group.
> > > > To post to this group, send email to spree-user@googlegroups.com.
> > > > To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
> > > > For more options, visit this group athttp://groups.google.com/group/spree-user?hl=en.
>
>

--
You received this message because you are subscribed to the Google Groups "Spree" group.
To post to this group, send email to spree-user@googlegroups.com.
To unsubscribe from this group, send email to spree-user+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/spree-user?hl=en.

Read More…

[Rails] Re: Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
Chris Kalaboukis wrote:
> Lasse Bunk wrote:
>> Hmm, strange – do you get some sort of javascript error?
>>
>> /Lasse
>>
>> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>
>
> No actually. Nothing happens at all. The jquery works (I think, can't
> relly test it since i can't get to the page i need to test it on without
> the prototype helpers) but the prototype is hosed. If I need to rewrite
> all of my helpers thats a huge ton of work.
>
> Thanks...chris

Actually...it gets even stranger, actually. When I first load it up, I
can use jquery OR prototype. But as soon as I use prototype, jquery
stops working. Prototype continues to work, but jquery is hosed. I guess
prototype takes back control or something?
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
Ok – just as a test, does it work if you delete these lines?

  jQuery.noConflict();
  jQuery(document).ready(
function() {
    jQuery("a[rel^='prettyPhoto']").prettyPhoto();
  });

/Lasse


2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>
Lasse Bunk wrote:
> Hmm, strange – do you get some sort of javascript error?
>
> /Lasse
>
> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>

No actually. Nothing happens at all. The jquery works (I think, can't
relly test it since i can't get to the page i need to test it on without
the prototype helpers) but the prototype is hosed. If I need to rewrite
all of my helpers thats a huge ton of work.

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

[Rails] Re: Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
Lasse Bunk wrote:
> Hmm, strange – do you get some sort of javascript error?
>
> /Lasse
>
> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>

No actually. Nothing happens at all. The jquery works (I think, can't
relly test it since i can't get to the page i need to test it on without
the prototype helpers) but the prototype is hosed. If I need to rewrite
all of my helpers thats a huge ton of work.

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

Read More…

[Rails] Re: Many-to-many relationship to table itself through other table

by rubyonrailsin 0 comments
mxrgus pxrt wrote:
> Hello,
>
> I would like to have many-to-many relationship to object itself with
> additional info, but I did not find any info on that, could someone
> suggest something?
>
> Example:
>
>
> Service
> -- name
> -- description
>
> ServiceConnection
> -- type
> -- description
> -- parent_id
> -- child_id

--------------------------------------------

Refer link given below..

http://www.noupe.com/ror/a-simple-twitter-app-with-ruby-on-rails-building-friendships.html
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
Hmm, strange – do you get some sort of javascript error?

/Lasse

2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>
Lasse Bunk wrote:
> Your noConflict solution is *almost* right. There is an error in that
> you
> call jquery (with lower case 'q') instead of jQuery (with upper case
> 'Q').
> This is probably also the reason why the rest of your javascripts /
> Prototype helpers stop working.
>
> Try editing it like so:
>
> <script type="text/javascript" charset="utf-8">
>   jQuery.noConflict();
>   jQuery(document).ready(function() {
>     jQuery("a[rel^='prettyPhoto']").prettyPhoto();
>   });
> </script>
>
> Does it work then?
>
> /Lasse
>
> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>

Hi Lasse:

Thanks for the tip. I made that change but my prototype helpers are
still hosed.   Is there something in the order of the libraries?
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…

Re: [Rails] grouping and acts_as_tree

by rubyonrailsin 0 comments
You can do it like this:

# this array is just my representation of your data
paths = [["Root", "child A", "child A1"],
         ["Root", "child A"],
         ["Root", "child B", "child B999", "child C245"],
         ["Root", "child D", "child B41"],
         ["Root", "child A", "child Axyz"]]

# you can do the grouping like this
groups = paths.group_by{ |p| p[1] }

puts groups.inspect # this is a hash

/Lasse

2010/3/26 tom <tomabroad@gmail.com>
hi & thx 4 ur time:



x = find.almost_all
<p>
<% for y in @x.ancestors.reverse %>
  <%= link_to h(y.title), y  %> &gt;
<% end %>
</p>

results in:


Root > child A > child A1
Root > child A >
Root > child B > child B999 > child C245
Root > child D > child B41
Root > child A > child Axyz
....
....
..

how can i group the list above lets say by the second level, eg like this:

CHILD A
Root > child A > child A1
Root > child A >
Root > child A > child Axyz

CHILD B
Root > child B > child B999 > child C245

CHILD D
Root > child D > child B41


or even by length after grouping by title (CHILD A):
Root > child A >
Root > child A > child A1
Root > child A > child Axyz




 



On Fri, Mar 26, 2010 at 1:37 PM, Lasse Bunk <lassebunk@gmail.com> wrote:
Tom,

Maybe it's just me but I don't quite understand... Could you explain what you're trying to achieve?

/Lasse

2010/3/24 tom <tomabroad@gmail.com>
hi,

im using acts_as_tree and im not sure on how to group find-result.

x = find.almost_all

<p>
<% for y in @x.ancestors.reverse %>
  <%= link_to h(y.title), page  %> &gt;
<% end %>
</p>

gives me a nice "breadcrum". but how is it possible to group the list lets say by the 1level or second level?

thx

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

[Rails] Re: Multilingual Email Within UserObserver?

by rubyonrailsin 0 comments
Hi Lasse,
Thank you. It might help.
Hugues
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: How to get last url??

by rubyonrailsin 0 comments
Rick Denatale wrote:
> On Fri, Mar 26, 2010 at 2:17 PM, Rutvij Pandya <lists@ruby-forum.com>
> wrote:
>> �How can I get lastly accessed url on my current page.
>> �i.e. user is on 'Posts' page & now if user wants to add new post for
>> that user needs to login first... for that user 'll be redirected to
>> login page...Now after getting logged in successfully user must be
>> redirected to the 'Posts' page again so that now he can add new post..
>>
> In a controller you can do request.url

You should also seriously consider using one of the authentication gems
that are available. They already solve this issue and many more. No need
to roll your own authentication system with all the options available.

I see that a lot of people seem to like AuthLogic, there is also Devise,
and several others.

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

Read More…

Re: [Rails] Re: Ruby 1.9 loading rails is slow

by rubyonrailsin 0 comments
On Fri, Mar 19, 2010 at 7:07 AM, ChrisT <ccthiel@gmail.com> wrote:
Rails 3.0.0.beta
And as far as loading rails, I mean anything involving the 'rails'
command. rails console, rails server, rails generate - all 30+
seconds.
Anything involve the rake tasks rails ships with: rake db:migrate,
rake test:units - 30+ seconds.
I honestly haven't even gotten into actually running the server yet -
I've been writing models and test units, but I did test on just
webrick and response time - 30+ seconds.
This is on Windows XP, Ubuntu 9.10 or Ubuntu 9.04 (both ubuntu were on
VirtualBox with XP as the host). I've tried Ruby 1.9.1 and 1.8.7.
1.8.7 just made things vastly worse - 2+ minutes to start some things.


Chris, these thing load for me in less than 5 seconds for Mac OS 10.6.2 and Ubuntu 9.10.
Windows 7 Ultimate can get things loaded in less than 20 seconds.  BTW, I have the following 
system configuration:

Mac Pro:

Mac OS 10.6.2
8-core 2.93 GHz
32 GB RAM
VMWare Fusion 3 - Windows 7 Ultimate (64 bit) and Ubuntu 9.10 (64 bit)

Also, I have scaled things all the way down using 1 and 2 cores and I was able to get the
same results.  Again, Rails 3 is currently in Beta.  Thus, all the needed optimizations are
not in place and I'm quite sure that there's a level of debugging logic within the code base.
This debugging logic will most likely be removed and optimizations will be put into place 
for the first release candidate (RC).

Good luck,

-Conrad


On Mar 18, 1:19 pm, Conrad Taylor <conra...@gmail.com> wrote:
> On Wed, Mar 10, 2010 at 2:44 PM, Andrius Chamentauskas
> <sinsil...@gmail.com>wrote:
>
> > Hello all,
>
> > I've recently started a project and I wanted to give ruby 1.9 + rails
> > a chance. Well everything works great, so far haven't encountered any
> > gem that didn't work (so anyone out there you should give it a try).
> > There's only one minor glitch: on ruby 1.8.7 loading rails environment
> > takes 1-2 secs, on 1.9.1 it takes ~10 secs. Maybe anyone had similar
> > problem? I'm on ubuntu 9.10 and I compiled ruby from source (as I've
> > noticed it works ~20% faster than apt version).
>
> What do you mean when you say loading Rails?  Command-line using webrick or
> thin?  Rails console?  Passenger?  Also, what version of Rails are you
> using?
>
> -Conrad
>
>
>
> >  --
> > 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-talk@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscribe@googlegroups.com<rubyonrails-talk%2Bunsubscrib e@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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…

[Rails] Timezone issue with legacy data stored in Eastern time

by rubyonrailsin 0 comments
Hello,

I've Googled and searched for this for many hours now and couldn't
find an answer although I did find a lot about timezones and rails.

Specifically I'm attaching a basic Rails CRUD frontend onto a legacy
database. The datetime fields in the database are stored as Eastern
Standard Time. There is a lot of legacy code that uses this database
and is expecting to get back times in EST, so I can't change them to
UTC.

Is there a way in Rails to tell ActiveRecord to use Eastern for
storing the datetime fields?

I've tried a number of combinations for config.time_zone and
config.active_record.default_timezone. FYI, rake time:zones:local
returns * UTC -06:00 * Central Time (US & Canada).

Any ideas would be greatly appreciated.

Thanks,
-Jonathan

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: How to calculate per_page value based on browser window size for will_paginate

by rubyonrailsin 0 comments
Why not allow the user to choose this value (i.e. via a drop down
menu )?

If you go that route, don't forget to store this preference somewhere
so your users don't have to set it every time. (I'm looking at you
Blockbuster.com)

Eric

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

Read More…

[Rails] Re: Using attachment_fu in existing user model with edit/upd

by rubyonrailsin 0 comments
> Hi Jodi,
>
> Thanks for the reply. I tried adding the additional table relationships
> as you suggested but I'm getting an error on the user update action:
> undefined local variable or method `filename' for #<User:0x2564508>
>
> I have the standard update code in my controller:
>
> def update
> @user = User.find(params[:id])
>
> respond_to do |format|
> if @user.update_attributes(params[:user])
> flash[:notice] = 'User was successfully updated.'
> format.html { redirect_to(@user) }
> format.xml { head :ok }
> else
> format.html { render :action => "edit" }
> format.xml { render :xml => @user.errors, :status =>
> :unprocessable_entity }
> end
> end
> end
>
> and the view code for the upload is:
> <%= file_field_tag :uploaded_data %>
>
> Any help is appreciated! Thanks.
>
> -Tony

I know this is an old post, but I was trying to find the solution to:
undefined local variable or method `filename'
and I arrived here.

I got this error because I made a mistake creating the table. I used
"file_name" instead of "filename". Changing this solved the problem for
me.

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

Read More…

[Rails] How to calculate per_page value based on browser window size for will_paginate

by rubyonrailsin 0 comments
def self.per_page
20
end

Any suggestion on how I can calculate this value base on the size of
the browser window?

Thanks

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Add all metods in ssl_required

by rubyonrailsin 0 comments
class SecureAreaController < ApplicationController

protected

def ssl_required?
Rails.env.production?
end

end

class CreditCardController < SecureAreaController

...

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

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

[Rails] Re: Prototype Helpers & jQuery

by rubyonrailsin 0 comments
Lasse Bunk wrote:
> Your noConflict solution is *almost* right. There is an error in that
> you
> call jquery (with lower case 'q') instead of jQuery (with upper case
> 'Q').
> This is probably also the reason why the rest of your javascripts /
> Prototype helpers stop working.
>
> Try editing it like so:
>
> <script type="text/javascript" charset="utf-8">
> jQuery.noConflict();
> jQuery(document).ready(function() {
> jQuery("a[rel^='prettyPhoto']").prettyPhoto();
> });
> </script>
>
> Does it work then?
>
> /Lasse
>
> 2010/3/26 Chris Kalaboukis <lists@ruby-forum.com>

Hi Lasse:

Thanks for the tip. I made that change but my prototype helpers are
still hosed. Is there something in the order of the libraries?
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] How to get last url??

by rubyonrailsin 0 comments
On Fri, Mar 26, 2010 at 2:17 PM, Rutvij Pandya <lists@ruby-forum.com> wrote:
> Dear all,
>
>  How can I get lastly accessed url on my current page.
>  i.e. user is on 'Posts' page & now if user wants to add new post for
> that user needs to login first... for that user 'll be redirected to
> login page...Now after getting logged in successfully user must be
> redirected to the 'Posts' page again so that now he can add new post..
>
In a controller you can do request.url

--
Rick DeNatale

Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale

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

Read More…

[Rails] How to get last url??

by rubyonrailsin 0 comments
Dear all,

How can I get lastly accessed url on my current page.
i.e. user is on 'Posts' page & now if user wants to add new post for
that user needs to login first... for that user 'll be redirected to
login page...Now after getting logged in successfully user must be
redirected to the 'Posts' page again so that now he can add new post..

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

Read More…

[Rails] Re: Custom validation

by rubyonrailsin 0 comments
The validations method you're trying to call is not a class method,
it's a validation helper so you can't call object.validation_method
(in this case Step.validates_numericality_of(...)).

The best way would be to declare customs validations if you want to
call them outside your class and then handle exception (begin/rescue
etc.), you should also use object.errors.add(attribute, 'custom error
message').

Cheers,
Emré.

On Mar 26, 7:43 am, Hugo Mag <li...@ruby-forum.com> wrote:
> Hi Mahmoud,
>
> Thanks for the info but the problem here is that my model does not have
> any validations declared because they depend on the workflow that the
> user sets.
>
> For instance, the user can set that in the Step 1 of the Workflow he
> wants to validate that a given attribute is greater than 300.
> To do this I need to call directly the validates_numericality_of class
> method:
>
> Step.validates_numericality_of(:attribute, :greater_than => 300)
>
> Best regards,
> Hugo
>
>
>
>
>
> Mahmoud Said wrote:
> > I believe you are not thinking in the proper use of validations.
>
> > What you want to do is:
>
> > s = Step.new
> > ...
>
> > s.valid?
> > s.errors.on(*attribute_to_be_validated*)  #returns nil for a valid
> > value. or
> > the error message in case the validation was not met
>
> > On Fri, Mar 26, 2010 at 2:36 AM, Hugo Mag <li...@ruby-forum.com> wrote:
>
> >> def Wrk < ActiveRecord::Base
> >> Posted viahttp://www.ruby-forum.com/.
>
> > --
> > Mahmoud Said
> > Software Engineer - eSpace
> > blog.modsaid.com
>
> --
> 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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Having Problems with collection_sellect

by rubyonrailsin 0 comments
On 26 March 2010 17:46, Gordons <godwinc.charles@gmail.com> wrote:
> Hello everybody, I am new to Ruby on Rails, while going through one of
> the tutorials, i found this program which I've been finding very
> difficult to run and see the output as it has been throwing many
> errors. Please can someone look into the codes and tell me how to
> debug it:
> <h1>Add new book</h1>
> <% form_tag do %>
> <%= 'create' %>
> <p><label for="book_title">Title</label>:
> <%= text_field_tag 'book', 'title' %></p>
> <p><label for="book_price">Price</label>:
> <%= text_field_tag 'book', 'price' %></p>
> <p><label for="book_subject">Subject</label>:
> <%= collection_select(:book,:subject_id,@subjects,:id,:name, :prompt
> => true) %></p>
> <p><label for="book_description">Description</label><br/>
> <%= text_area 'book', 'description' %></p>
> <%= submit_tag "Create" %>
> <% end %>
> <%= link_to 'Back', {:action => 'list'} %>
>
> The errors it throws are:
>
>  NoMethodError in Book#new
>
> Showing app/views/book/new.rhtml where line #9 raised:
>
> undefined method `subject_id' for #<Book id: nil, created_at: nil,
> updated_at: nil>

That would appear to be saying that the book class does not have a
field subject_id

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

Read More…

Re: [Rails] grouping and acts_as_tree

by rubyonrailsin 0 comments
hi & thx 4 ur time:


x = find.almost_all
<p>
<% for y in @x.ancestors.reverse %>
  <%= link_to h(y.title), y  %> &gt;
<% end %>
</p>

results in:


Root > child A > child A1
Root > child A >
Root > child B > child B999 > child C245
Root > child D > child B41
Root > child A > child Axyz
....
....
..

how can i group the list above lets say by the second level, eg like this:

CHILD A
Root > child A > child A1
Root > child A >
Root > child A > child Axyz

CHILD B
Root > child B > child B999 > child C245

CHILD D
Root > child D > child B41


or even by length after grouping by title (CHILD A):
Root > child A >
Root > child A > child A1
Root > child A > child Axyz



 



On Fri, Mar 26, 2010 at 1:37 PM, Lasse Bunk <lassebunk@gmail.com> wrote:
Tom,

Maybe it's just me but I don't quite understand... Could you explain what you're trying to achieve?

/Lasse

2010/3/24 tom <tomabroad@gmail.com>
hi,

im using acts_as_tree and im not sure on how to group find-result.

x = find.almost_all

<p>
<% for y in @x.ancestors.reverse %>
  <%= link_to h(y.title), page  %> &gt;
<% end %>
</p>

gives me a nice "breadcrum". but how is it possible to group the list lets say by the 1level or second level?

thx

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

[Rails] Having Problems with collection_sellect

by rubyonrailsin 0 comments
Hello everybody, I am new to Ruby on Rails, while going through one of
the tutorials, i found this program which I've been finding very
difficult to run and see the output as it has been throwing many
errors. Please can someone look into the codes and tell me how to
debug it:
<h1>Add new book</h1>
<% form_tag do %>
<%= 'create' %>
<p><label for="book_title">Title</label>:
<%= text_field_tag 'book', 'title' %></p>
<p><label for="book_price">Price</label>:
<%= text_field_tag 'book', 'price' %></p>
<p><label for="book_subject">Subject</label>:
<%= collection_select(:book,:subject_id,@subjects,:id,:name, :prompt
=> true) %></p>
<p><label for="book_description">Description</label><br/>
<%= text_area 'book', 'description' %></p>
<%= submit_tag "Create" %>
<% end %>
<%= link_to 'Back', {:action => 'list'} %>

The errors it throws are:

NoMethodError in Book#new

Showing app/views/book/new.rhtml where line #9 raised:

undefined method `subject_id' for #<Book id: nil, created_at: nil,
updated_at: nil>

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

Read More…

[Rails] EARN MONEY IN FREE TIME(DO MORE & EARN MORE)

by rubyonrailsin 0 comments
Read More…

Re: [Rails] Multilingual Email Within UserObserver?

by rubyonrailsin 0 comments
Hugues,

Robby Russell has a pretty good blog post about this subject – sending email from controllers vs. models. Please read the comments as well as there's a lot of helpful discussion going on there. I think I'm going with sending emails from the controller, which in your case would make it easier to send email in different languages. However, if you prefer to send the email from your observer, a solution could be to store the user's language in the user model.

Hope this helps.

/Lasse

2010/3/24 Hugues Brunelle <lists@ruby-forum.com>
Hello,

I have a beta testing program for a multilingual webapp using globalite.
People register on the website in english or in french.

I use a UserObserver from acts_as_authenticated plugin that send an
email with an activation code to validate registration.
Depending on which language... I need to send the good email.

Using the after_create within UserObserver, is there a way to pass the
language variable in the model or do I need to setup this in the
controller?

Or is there any other way to achieve this beside sending a multilingual
email hehe.

Thx a lot for your time and advises.

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

Re: [Rails] grouping and acts_as_tree

by rubyonrailsin 0 comments
Tom,

Maybe it's just me but I don't quite understand... Could you explain what you're trying to achieve?

/Lasse

2010/3/24 tom <tomabroad@gmail.com>
hi,

im using acts_as_tree and im not sure on how to group find-result.

x = find.almost_all

<p>
<% for y in @x.ancestors.reverse %>
  <%= link_to h(y.title), page  %> &gt;
<% end %>
</p>

gives me a nice "breadcrum". but how is it possible to group the list lets say by the 1level or second level?

thx

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

Re: [Rails] Active Record relations

by rubyonrailsin 0 comments
Hi Rajkumar,

This is pretty basic Rails – it might be a good idea to study up on the Ruby on Rails guides and the Agile Web Development with Rails book. I hope this is okay for you.

/Lasse

2010/3/25 Rajkumar Surabhi <lists@ruby-forum.com>
HI all

in my application , i have 2 tables subjects and teachers. the relation
is one to many.

i have to display the subjects first and when i click on the subjects i
have to display the teachers.

and i have to add the new teacher to the teachers table by selecting the
subject.

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

Re: [Rails] auto_complete: if no results returned, what gets submitted?

by rubyonrailsin 0 comments
Wim,

I just tried it out, and it works fine for me – if I type a name that doesn't exist, then that name is submitted.

In the controller:

  auto_complete_for :supplier, :name

In the action:

  render :text => "Name = #{params[:supplier][:name]}"

And in the view:

  <%= text_field_with_auto_complete :supplier, :name %>

If this doesn't help you, maybe you could post some code?

/Lasse

2010/3/25 Wim Van Dijck <google@sinoid.be>
Hi,

I'm a rails noob, tring to teach myself, so feel free to point me to
the correct FM if need be ;-)

I'm playing with the auto_complete plugin. I have a page to manage
expenses, and there's field 'supplier' to whom the expense is paid.
I can successfully retrieve the suppliers name from the suppliers
table, but when I type a name that doesn't exist yet, and submit,
nothing gets submitted?

Can anyone shed any light to why that is?
Ideally, in this situation, I'd like to be redirected to the supplier
model 'new' page, but I can settle for it just accepting what I type?

Best regards,
Wim

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

[Rails] ActiveRecord setting empty strings to nil for Numeric attributes

by rubyonrailsin 0 comments
I have an ActiveRecord model with several float attributes that takes
input directly from the user, and they are all set to not null in the
DB. When any of these attributes are set to an empty string (""),
their value is instead set to nil. This only occurs with an empty
string, setting them to any non-empty string, even just whitespace,
sets their values to that of the string. Trying to save a new record
with any of these values set to nil results in a column cannot be null
error. However, if this is done to a non-new record results in the
nil's being cast back to float before saving.

Is there any way to force AR to cast the nil float attributes to float
on insert, just like it does on update (other than doing it explicitly
in validate or a callback)? Or, is there a to make AR not change an
empty string to nil when it is set?

Thanks,
Chris

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

Read More…

Re: [Rails] Many-to-many relationship to table itself through other table

by rubyonrailsin 0 comments
On 26 March 2010 11:16, mxrgus pxrt <margus.part@ria.ee> wrote:
> Hello,
>
> I would like to have many-to-many relationship to object itself with
> additional info, but I did not find any info on that, could someone
> suggest something?
>
> Example:
>
>
> Service
> -- name
> -- description
>
> ServiceConnection
> -- type
> -- description
> -- parent_id
> -- child_id

Have a look at has_many :through with class_name and foreign_key. You
will need two of these, one for parents and one for children.
has_many :service_connections
has_many :parents, :through => :service_connection, :class_name..... etc
has_many :children, :through => :service_connection, :class_name..... etc

The rails guide on activerecord associations at
http://guides.rubyonrails.org/ should help.

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

Read More…

Re: [Rails] Re: How to include a ruby gem environment.rb file?

by rubyonrailsin 0 comments
Jorge,

Nice – good you got it working :)

/Lasse

2010/3/26 Jorge alejandro Mendoza torres <lists@ruby-forum.com>
Hi Lasse.

I had an application in version 2.0.2 and I changed the version of the
application already had, I thought it would be harder, but it was very
easy.

On the page you mention, as I checked it, and is very helpful.

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

[Rails] Re: how to insert a batch of records into db more efficientl

by rubyonrailsin 0 comments
My friend Jonah wrote Crewait, which is easier and faster than
ARExtensions for bulk insertion.

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

Read More…

Re: [Rails] Converting TrueClass / FalseClass to integer.

by rubyonrailsin 0 comments
Hi Nick,

That's a good question :-)
I think a DRY way could be doing it like this:

  module BooleanToInteger
    def to_i
      self ? 1 : 0
    end
  end

  [TrueClass, FalseClass].each { |c| c.send :include, BooleanToInteger }

Hope this helps.

/Lasse

2010/3/26 nick ger <lists@ruby-forum.com>
Hello.

I'm trying to figure out if there is an easy way to do the following
short of adding to_i method to TrueClass/FalseClass.

Here is a dilemma:
I have a boolean field in my rails app - that is obviously stored as
Tinyint in mysql. However - I need to generate xml based of the data in
mysql and send it to  customer - there SOAP service requires the field
in question to have 0 or 1 as the value of this field. So at the time of
the xml generation I need to convert my False to 0 and my True to 1 (
which is how they are stored in the DB). Since True & False lack to_i
method I could write some if statement that generate either 1 or 0
depending on true/false state. However I have about 10 of these
indicators and creating and if/else for each is not very DRY. So what
you recommend I do?

Or I could add a to_i method to the True / False class.  But I'm not
sure where should I scope it in my rails app? Just inside this
particular model or somewhere else?
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Read More…

[Rails] Converting TrueClass / FalseClass to integer.

by rubyonrailsin 0 comments
Hello.

I'm trying to figure out if there is an easy way to do the following
short of adding to_i method to TrueClass/FalseClass.

Here is a dilemma:
I have a boolean field in my rails app - that is obviously stored as
Tinyint in mysql. However - I need to generate xml based of the data in
mysql and send it to customer - there SOAP service requires the field
in question to have 0 or 1 as the value of this field. So at the time of
the xml generation I need to convert my False to 0 and my True to 1 (
which is how they are stored in the DB). Since True & False lack to_i
method I could write some if statement that generate either 1 or 0
depending on true/false state. However I have about 10 of these
indicators and creating and if/else for each is not very DRY. So what
you recommend I do?

Or I could add a to_i method to the True / False class. But I'm not
sure where should I scope it in my rails app? Just inside this
particular model or somewhere else?
--
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-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Read More…

Re: [Rails] Admin Sections & Roles

by rubyonrailsin 0 comments
If you need some inspiration, you could take a look at the role_requirement plugin. It works with restful-authentication – I think it's great.

/Lasse

2010/3/26 brianp <brian.o.pearce@gmail.com>
Hey everyone.

In the last app I made it was fairly straight forward. Front end for
users, admin area for admin.

This app is a little more complicated and I wanted your opinions on
the best strategy.

The site will have Site Admin (myself and moderators.)

Dealers may sign up to the site and have there own
"Storefronts." (store fronts may have only one owner or master admin
but multiple users for maintenance)

the Dealers require a smaller admin section for there storefront.

Customers may come and browse the entire site including all available
Storefronts.

Would it be better to run two different logins with 2 different user
tables? SiteWideAdmin and Dealers. Or one master login with one user
table and allot of permissions & roles spread all over ?

Cheers,
brianp

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

Re: [Rails] for loops

by rubyonrailsin 0 comments
for i in 1..8 do
puts i
end

The above loop will result in the following output:
1
2
3
4
5
6
7
8

I don't think there's anything else to explain here.

On 26 March 2010 14:44, woodsy0130 <woodsy0130@hotmail.com> wrote:
> Could someone please give me a brief explanation on for loops please


--
Viele Grüße / Best regards,
Björn Wilmsmann

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

Read More…

[Rails] Many-to-many relationship to table itself through other table

by rubyonrailsin 0 comments
Hello,

I would like to have many-to-many relationship to object itself with
additional info, but I did not find any info on that, could someone
suggest something?

Example:


Service
-- name
-- description

ServiceConnection
-- type
-- description
-- parent_id
-- child_id

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

Read More…

[Rails] exporting table data as a html file

by rubyonrailsin 0 comments
I have a model named "notice.rb" with a corresponding controller
"notices_controller.rb" and my db table "notices" contains two text
fields - title and body.

I want to save this table data as an html file in a external
directory. Please help me and suggest me ways to do it. NB: This html
file is not the view corresponding to this model but it should be a
different "html file". You can say that its like exporting data in
html format.

Here is my code for the model and controller....

#notices_controller.rb
class NoticesController < ApplicationController
before_filter :login_required

def new
end

def create
@notice = Notice.new(params[:notice])
@notice.save
flash.now[:notice] = "Notice created successfully"
render :action => 'show'
end

def show
@notice = Notice.find(:all)
end
end

#notice.rb
class Notice < ActiveRecord::Base
belongs_to :user

validates_presence_of :title, :body
attr_accessible :title, :body
end

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

Read More…

Subscribe feeds via e-mail

Blog Archive