[Rails] Re: find a string in a file

2011-06-05 Thread AGoofin
Should be able to do something like to separate the tasks:

u = open( "myfile" )
  while line = u.gets
if line.include?( "taske :" )
  anArray = line.split(' ')
  puts anArray[1] if anArray.length > 0
end
  end

You could even combine the split function with the index function
line,split(' ')[1] if you are sure where the target info will be.

Note: Don't be afraid to try different things. This solution is only
one of many and others here could do a lot better. You could do better
with a little practice and research.


On Jun 5, 7:08 pm, Adel Mediouni  wrote:
> hi
> i want to find a string in file then retrieve the rest,this is an
> exemple of a line:
> taske :say_hellow do
> i want retrieve just "say_hellow"
> so how can i do please.
> 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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] find a string in a file

2011-06-05 Thread Adel Mediouni
hi
i want to find a string in file then retrieve the rest,this is an
exemple of a line:
taske :say_hellow do
i want retrieve just "say_hellow"
so how can i do please.
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Filters

2011-06-05 Thread Bill Walton
Hi Fernando,

On Sun, Jun 5, 2011 at 3:59 PM, Fernando Aureliano
 wrote:
> Hi,
> How I do a filter in a block of code?
> example:
> I have a block:
> <% @notes[(0..3)].each do |note| %>
   <% if notes.type.class == String %>
>           
>             <%= notes.note %>
>             <%= notes.type %>
>           
  <% end %>
> <% end %>
> Type is a string, I would like to do a block filtering by a value on type.

However, your code will be much more testable if you do the filtering
on @notes in the controller, or even better, by writing a method in
your model that only returns records with type of class String.


HTH,
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-talk@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] Filters

2011-06-05 Thread Fernando Aureliano
Hi,

How I do a filter in a block of code?

example:

I have a block:

<% @notes[(0..3)].each do |note| %>
  
<%= notes.note %>
<%= notes.type %>
  
<% end %>

Type is a string, I would like to do a block filtering by a value on type.




Thanks!

-- 
*Fernando Aureliano*

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



Re: [Rails] Built in (boolean)? method

2011-06-05 Thread Colin Law
On 5 June 2011 21:35, Chris Mear  wrote:
>  < loads of useful and interesting stuff.>

What a great list, ask some questions and get excellent answers.  Thanks Chris.

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



Re: [Rails] Built in (boolean)? method

2011-06-05 Thread Chris Mear
On 5 June 2011 10:15, Colin Law  wrote:

> I have never used the for_charity? syntax though.  There does not seem
> much point when it is a boolean.

I've been using it ever since reading dire warnings in the first
edition of Agile Web Development with Rails:

"[To represent true or false, some databases] use integer columns,
where 0 is false and 1 is true... The problem is that in Ruby the
number 0 and the string "f" are both interpreted as true values in
conditions... To query a column as a boolean value in a condition, you
must append a question mark to the column's name"

I must confess I was surprised to learn (prompted by this thread) that
Active Record has a feature that emulates boolean columns for
databases that don't support them natively, so you do get a literal
true or false value out of the attribute, instead of a 1 or 0. And was
even more surprised to learn that this feature was added quite a long
time ago (version 1-ish, AFAICT).

But warnings like the above are still passed on (and in fact are still
present in the current edition of AWDWR). I and others clearly missed
the memo.

> Is that syntax documented somewhere?

It's currently implemented in ActiveRecord::AttributeMethods::Query,
and mentioned in the preamble doc for ActiveRecord::Base (but only as
a way of checking for the presence of attributes, not as a way to
typecast fake boolean columns).

The MySQL connection adaptor's boolean emulation behaviour is
configurable via
ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans, which
is documented.

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



[Rails] Re: ActiveRecord array/collection manage

2011-06-05 Thread Allan
Should it be:

class Car < ActiveRecord::Base
  def self.color(c)
...
  end
end

Allan

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/QWlTM2tvR1IzSU1K.
To post to this group, send email to rubyonrails-talk@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: Different user sessions with different domain name?

2011-06-05 Thread tashfeen.ekram
This has been great advice. I am using nginx. (I know this is now not
a rails questions, but I figured to complete the post here so as not
to cross post). The way to to do this on nginx is as follows:

server {
  listen  80;
  server_name domain.com *.domain.com;
  rewrite ^   http://www.domain.com$request_uri? permanent;
 }

server {
  listen  80;
  server_name www.domain.com;

  index   index.html;
  root/home/domain.com
}

This is taken from:

http://blog.martinfjordvald.com/2010/07/nginx-primer/

On Jun 2, 5:10 am, Chris Kottom  wrote:
> Yes, important point there.  The choice to host across multiple subdomains
> should be made for a reason, not by default.  If the subdomain is an
> essential part of the user's request (Google up "Basecamp style subdomains"
> if you're not sure what I mean by this) then it's possible that you'd want
> separate cookies for each subdomain.  In the vast majority of cases however,
> the application isn't inferring anything from the subdomain, and you're
> potentially losing PageRank.
>
> Making the configuration at the web server will help you with both problems,
> if it is in fact a problem to have more than one subdomain, whereas the
> Rails-only solution helps only with cookie management.
>
> On Thu, Jun 2, 2011 at 9:53 AM, ratnadeepdeshm...@gmail.com <
>
>
>
>
>
>
>
> ratnadeepdeshm...@gmail.com> wrote:
> > But overall redirection from non www to www or vice versa should be done at
> > least for "www" subdomain.. As google bot considers www and non www as two
> > different sites.
>
> > So go with Apache configs way if you want www and non www to be same.
>
> > And go with Rails cookies way, if you really have some subdomains like
> > app1.example.com and app2.example.com, where app1 and app2 are sharing the
> > session.
>
> > On Thu, Jun 2, 2011 at 9:18 AM, jiblethead  wrote:
>
> >> > in config/initializers/session_store.rb
>
> >> > MyApp::Application.config.session_store :cookie_store, :key =>
> >> > '_my_app_session', :domain => 'xxx.com'
>
> >> the solution I've found to work consistently is to modify as above,
> >> but set :domain => '.xxx.com'
>
> >> Having the leading period (.) will set a common cookie that is shared
> >> by all subdomains.  I use this technique to handle a secure subdomain
> >> vs. a www subdomain, without creating new sessions between the two.
>
> >> Kevin
>
> >> --
> >> 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+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >>http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > --
> > Ratnadeep Deshmane.
> >http://rtdptech.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+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-talk@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] Power Point / Keynote presentation in website

2011-06-05 Thread Chad Eubanks
Hi,

I actually use keynote to prototype all my applications with the exception of 
mobile apps.  I use dashboard for mobile apps.  The front end technology my 
team uses is SproutCore and the animation framework is awesome.  

SproutCore provides good cross browser support and would highly recommend it.  
Check out the following demos and git account for sample code:

animate.strobeapp.com
animatedemo.strobeapp.com
http://guidesdev.sproutcore.com/animate.html
github.com/thecodeboutique

Furthermore, we will be releasing training material for SproutCore on the front 
end and rails on the backend shortly at sproutcoreonrails.com.  I will keep the 
community up to date when I can provide more information.

Kind Regards,
Chad Eubanks
The Code Boutique


Sent from my iPad

On Jun 5, 2011, at 10:10 AM, Peter De Berdt  wrote:

> Most of the effects can either be achieved with CSS3 (animations) or 
> Javascript, Rails is all about the serverside, these kinds of animations are 
> clientside and thus need clientside scripting. Keep in mind that CSS3 
> animation support is very limited at this time in most of the current 
> browsers (Safari seems to be way ahead of everyone else on the animation 
> front). Also, it's not going to be a trivial task to achieve that kind of 
> animation.
> 
> For what it's worth, I myself and quite a few people I know (even 
> non-developers) hate this kind of site where you have to wait for about 15 
> seconds before the actual content appears. It doesn't add anything useful to 
> the site itself, except for a delay in getting to the information you want. 
> Animation should be an added value, not a means of being fancy and dandy.
> 
> However, looking back at your original question (and the title of this 
> thread), you are looking for Powerpoint/Keynote-like transitions. As I 
> originally responded, both of these can be achieved with CSS3 (most 
> performant on mobile devices) or Javascript (works cross-browser).
> 
> On 05 Jun 2011, at 18:57, Rodrigo Ruiz wrote:
> 
>> Ya, I was just looking at the source and found out it was flash... But how 
>> can I do the same thing with Rails and without flash?
>> 
>> On Sun, Jun 5, 2011 at 12:26 PM, Colin Law  wrote:
>> On 5 June 2011 17:15, Rodrigo Ruiz  wrote:
>> > Hi, I'd like to know how can I do something like that entrance:
>> > http://www.ibderma.com.br/index_02.html
>> > I think it can be done with Power Point or Keynote (even better if 
>> > possible,
>> > cause I'm on a mac), but I have no idea how, if anyone can help me I
>> > appreciate it.
>> 
>> That is not really a Rails question, but the effect is done using
>> Flash.  Please don't do it, it is horrible to have a site that relies
>> on flash.  Think of those with limited bandwidth.  Also it will not
>> work on many mobiles, and some users disable flash due to the security
>> issues.
> 
> 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-talk@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-talk@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] Power Point / Keynote presentation in website

2011-06-05 Thread Rodrigo Ruiz
Thank you very much, tell me one more thing, can I do that javascript part
with only ruby language?

On Sun, Jun 5, 2011 at 1:10 PM, Peter De Berdt wrote:

> Most of the effects can either be achieved with CSS3 (animations) or
> Javascript, Rails is all about the serverside, these kinds of animations are
> clientside and thus need clientside scripting. Keep in mind that CSS3
> animation support is very limited at this time in most of the current
> browsers (Safari seems to be way ahead of everyone else on the animation
> front). Also, it's not going to be a trivial task to achieve that kind of
> animation.
>
> For what it's worth, I myself and quite a few people I know (even
> non-developers) hate this kind of site where you have to wait for about 15
> seconds before the actual content appears. It doesn't add anything useful to
> the site itself, except for a delay in getting to the information you want.
> Animation should be an added value, not a means of being fancy and dandy.
>
> However, looking back at your original question (and the title of this
> thread), you are looking for Powerpoint/Keynote-like transitions. As I
> originally responded, both of these can be achieved with CSS3 (most
> performant on mobile devices) or Javascript (works cross-browser).
>
> On 05 Jun 2011, at 18:57, Rodrigo Ruiz wrote:
>
> Ya, I was just looking at the source and found out it was flash... But how
> can I do the same thing with Rails and without flash?
>
> On Sun, Jun 5, 2011 at 12:26 PM, Colin Law  wrote:
>
>> On 5 June 2011 17:15, Rodrigo Ruiz  wrote:
>> > Hi, I'd like to know how can I do something like that entrance:
>> > http://www.ibderma.com.br/index_02.html
>> > I think it can be done with Power Point or Keynote (even better if
>> possible,
>> > cause I'm on a mac), but I have no idea how, if anyone can help me I
>> > appreciate it.
>>
>> That is not really a Rails question, but the effect is done using
>> Flash.  Please don't do it, it is horrible to have a site that relies
>> on flash.  Think of those with limited bandwidth.  Also it will not
>> work on many mobiles, and some users disable flash due to the security
>> issues.
>>
>
> 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-talk@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-talk@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] Power Point / Keynote presentation in website

2011-06-05 Thread Peter De Berdt
Most of the effects can either be achieved with CSS3 (animations) or  
Javascript, Rails is all about the serverside, these kinds of  
animations are clientside and thus need clientside scripting. Keep in  
mind that CSS3 animation support is very limited at this time in most  
of the current browsers (Safari seems to be way ahead of everyone else  
on the animation front). Also, it's not going to be a trivial task to  
achieve that kind of animation.


For what it's worth, I myself and quite a few people I know (even non- 
developers) hate this kind of site where you have to wait for about 15  
seconds before the actual content appears. It doesn't add anything  
useful to the site itself, except for a delay in getting to the  
information you want. Animation should be an added value, not a means  
of being fancy and dandy.


However, looking back at your original question (and the title of this  
thread), you are looking for Powerpoint/Keynote-like transitions. As I  
originally responded, both of these can be achieved with CSS3 (most  
performant on mobile devices) or Javascript (works cross-browser).


On 05 Jun 2011, at 18:57, Rodrigo Ruiz wrote:

Ya, I was just looking at the source and found out it was flash...  
But how can I do the same thing with Rails and without flash?


On Sun, Jun 5, 2011 at 12:26 PM, Colin Law   
wrote:

On 5 June 2011 17:15, Rodrigo Ruiz  wrote:
> Hi, I'd like to know how can I do something like that entrance:
> http://www.ibderma.com.br/index_02.html
> I think it can be done with Power Point or Keynote (even better if  
possible,

> cause I'm on a mac), but I have no idea how, if anyone can help me I
> appreciate it.

That is not really a Rails question, but the effect is done using
Flash.  Please don't do it, it is horrible to have a site that relies
on flash.  Think of those with limited bandwidth.  Also it will not
work on many mobiles, and some users disable flash due to the security
issues.


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-talk@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] ActiveRecord array/collection manage

2011-06-05 Thread Valery Kvon
Pagination obviously doesn't works on Array, but ActiveRecord::Relation set.

You have to rewrite your color selector using 'standard de facto' approach:

class Car < ActiveRecord::Base
  scope :colored, lambda { |color| where(:color => color) }
end

Then just call:

Car.colored(%w{red blue}).page ... etc


On 05.06.2011, at 20:11, danimashu wrote:

> Hello, I have a model like this:
> 
> class Car < ActiveRecord::Base
>  def color(c)
>where("color = ?",c)
>  end
> 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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Power Point / Keynote presentation in website

2011-06-05 Thread Rodrigo Ruiz
Ya, I was just looking at the source and found out it was flash... But how
can I do the same thing with Rails and without flash?

On Sun, Jun 5, 2011 at 12:26 PM, Colin Law  wrote:

> On 5 June 2011 17:15, Rodrigo Ruiz  wrote:
> > Hi, I'd like to know how can I do something like that entrance:
> > http://www.ibderma.com.br/index_02.html
> > I think it can be done with Power Point or Keynote (even better if
> possible,
> > cause I'm on a mac), but I have no idea how, if anyone can help me I
> > appreciate it.
>
> That is not really a Rails question, but the effect is done using
> Flash.  Please don't do it, it is horrible to have a site that relies
> on flash.  Think of those with limited bandwidth.  Also it will not
> work on many mobiles, and some users disable flash due to the security
> issues.
>
> 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+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-talk@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] RoR/Ruby slowness

2011-06-05 Thread Hassan Schroeder
On Sun, Jun 5, 2011 at 9:34 AM, Tom Meinlschmidt  wrote:

> still fighting with incredible ruby slowness with RoR development. Not only 
> tests, but whole development takes
> a lot of time, getting eg. 2000ms to complete page render (with mysql5).

Install either
  rails-footnotes  -- http://rubygems.org/gems/rails-footnotes
or
  new relic rpm -- http://newrelic.com/

to collect real data on where the time is being taken. It could be DB,
it could be rendering, it could be a combination of things.

HTH,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com
http://about.me/hassanschroeder
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-talk@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] RoR/Ruby slowness

2011-06-05 Thread Tom Meinlschmidt
Hi all,

still fighting with incredible ruby slowness with RoR development. Not only 
tests, but whole development takes
a lot of time, getting eg. 2000ms to complete page render (with mysql5). Trying 
various versions of ruby (1.8.7, 1.9.1, 1.9.2), but
still the same. Using mbp late 2009, 4gb ram, osx 10.6.7 

anyone experiencing the same?

thx
tom

-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



Re: [Rails] Power Point / Keynote presentation in website

2011-06-05 Thread Colin Law
On 5 June 2011 17:15, Rodrigo Ruiz  wrote:
> Hi, I'd like to know how can I do something like that entrance:
> http://www.ibderma.com.br/index_02.html
> I think it can be done with Power Point or Keynote (even better if possible,
> cause I'm on a mac), but I have no idea how, if anyone can help me I
> appreciate it.

That is not really a Rails question, but the effect is done using
Flash.  Please don't do it, it is horrible to have a site that relies
on flash.  Think of those with limited bandwidth.  Also it will not
work on many mobiles, and some users disable flash due to the security
issues.

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



[Rails] Power Point / Keynote presentation in website

2011-06-05 Thread Rodrigo Ruiz
Hi, I'd like to know how can I do something like that entrance:
http://www.ibderma.com.br/index_02.html

I think it can be done with Power Point or Keynote (even better if possible,
cause I'm on a mac), but I have no idea how, if anyone can help me I
appreciate it.

Thank you,
Rodrigo


Ps.: I love this community, every question I've asked so far, someone helped
me =), thank you.

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



[Rails] ActiveRecord array/collection manage

2011-06-05 Thread danimashu
Hello, I have a model like this:

class Car < ActiveRecord::Base
  def color(c)
where("color = ?",c)
  end
end

Suppose that I want to show the red and blue cars. I could do
something like this:
@cars = Car.color('blue') + Car.color('red')

The problem I'm finding is that now, @cars is an array and I could not
do something like that:
@cars.page(params[:page]).per(10)
@cars.order( . )
or any method ActiveRecord implements. The question is: ¿How can I
manage ActiveRecord array/collection for do: + - | &?

Thanks very much.

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



Re: [Rails] Newbie question

2011-06-05 Thread Fernando Aureliano
Sorry, works now.

On Sun, Jun 5, 2011 at 11:45 AM, Fernando Aureliano <
m...@fernandoaureliano.com> wrote:

> I'm getting an error with this sintax =(
>
>  <%= link_to article.title, article_path(article) %>
>
> On Sat, Jun 4, 2011 at 7:36 PM, Fernando Aureliano <
> m...@fernandoaureliano.com> wrote:
>
>> Nops, thats it. Thanks! =D
>>
>>
>> On Sat, Jun 4, 2011 at 7:25 PM, Valery Kvon  wrote:
>>
>>> <% articles.each do |article| %>
>>>   <%= link_to article.title, article_path(article) %>
>>> <% end %>
>>>
>>> Is that you figuring out or I missed something wrong?
>>>
>>>
>>>
>>>
>>> I'm new on rails, and I would like like to know how I do for I get a
>>> link on title on a block of code (each), and do this link go to show
>>> function and show up.
>>>
>>> should be something like "link_to article.title, article_path"? I
>>> already tried that and I get broken the page.
>>>  *^ send article object!*
>>>
>>>
>>>  --
>>> 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+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>>
>>
>>
>>
>> --
>> *Fernando Aureliano*
>> --
>> [iOSDeveloper] - *ObjectiveC*
>> [WebDesigner] - *CSS3&HTML5*
>> *[WebDeveloper] - RubyOnRails*
>> *--
>> *
>> [portfolio]  - 
>> [blog]
>>  - [personal blog]  - 
>> [twitter]
>>
>>
>
>
> --
> *Fernando Aureliano*
> --
> [iOSDeveloper] - *ObjectiveC*
> [WebDesigner] - *CSS3&HTML5*
> *[WebDeveloper] - RubyOnRails*
> *--
> *
> [portfolio]  - 
> [blog]
>  - [personal blog]  - 
> [twitter]
>
>


-- 
*Fernando Aureliano*
--
[iOSDeveloper] - *ObjectiveC*
[WebDesigner] - *CSS3&HTML5*
*[WebDeveloper] - RubyOnRails*
*--
*
[portfolio]  -
[blog]
 - [personal blog]  -
[twitter]

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



Re: [Rails] Newbie question

2011-06-05 Thread Fernando Aureliano
I'm getting an error with this sintax =(

 <%= link_to article.title, article_path(article) %>

On Sat, Jun 4, 2011 at 7:36 PM, Fernando Aureliano <
m...@fernandoaureliano.com> wrote:

> Nops, thats it. Thanks! =D
>
>
> On Sat, Jun 4, 2011 at 7:25 PM, Valery Kvon  wrote:
>
>> <% articles.each do |article| %>
>>   <%= link_to article.title, article_path(article) %>
>> <% end %>
>>
>> Is that you figuring out or I missed something wrong?
>>
>>
>>
>>
>> I'm new on rails, and I would like like to know how I do for I get a link
>> on title on a block of code (each), and do this link go to show function and
>> show up.
>>
>> should be something like "link_to article.title, article_path"? I already
>> tried that and I get broken the page.
>>  *^ send article object!*
>>
>>
>>  --
>> 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+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/rubyonrails-talk?hl=en.
>>
>
>
>
> --
> *Fernando Aureliano*
> --
> [iOSDeveloper] - *ObjectiveC*
> [WebDesigner] - *CSS3&HTML5*
> *[WebDeveloper] - RubyOnRails*
> *--
> *
> [portfolio]  - 
> [blog]
>  - [personal blog]  - 
> [twitter]
>
>


-- 
*Fernando Aureliano*
--
[iOSDeveloper] - *ObjectiveC*
[WebDesigner] - *CSS3&HTML5*
*[WebDeveloper] - RubyOnRails*
*--
*
[portfolio]  -
[blog]
 - [personal blog]  -
[twitter]

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



[Rails] How to Choose the Best Web Hosting Service

2011-06-05 Thread ebraheeem
some advices to guide you to choose the best host service
 through this link

http://besthostservice.blogspot.com/

Be Happy

and you can see some of the best host service for free on this link

http://besthostservice.blogspot.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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Cancan redirect back at AccessDenied

2011-06-05 Thread koulikoff
If your request does not have the HTTP_REFERER defined,
redirect_to :back does not know where to redirect.
Ususally in this case root_url is used.
I hope, it will not be too difficult for you to combine

On Jun 5, 1:28 pm, Yiannis  wrote:
> Hello
>
> I have a rails 3 app and I am trying to implement the redirect back
> action at access denied for cancan.
>
> If I try this in my application_controller:
>   rescue_from CanCan::AccessDenied do |exception|
>         redirect_to :back
>   end
>
> It gives the following error:
> No HTTP_REFERER was set in the request to this action, so
> redirect_to :back could not be called successfully. If this is a test,
> make sure to specify request.env["HTTP_REFERER"].
>
> I can't really understand why there is no http_referer, how is back
> button working on views? Is it possible to implement a general back
> action for the cancan access denied exception?
>
> I like the devise approach of "back" method after sign in:
> def after_sign_in_path_for(resource)
> stored_location_for(resource)
> end
>
> It would be perfect if I could combine them.
>
> Thank you!

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



[Rails] Cancan redirect back at AccessDenied

2011-06-05 Thread Yiannis
Hello

I have a rails 3 app and I am trying to implement the redirect back
action at access denied for cancan.

If I try this in my application_controller:
  rescue_from CanCan::AccessDenied do |exception|
redirect_to :back
  end

It gives the following error:
No HTTP_REFERER was set in the request to this action, so
redirect_to :back could not be called successfully. If this is a test,
make sure to specify request.env["HTTP_REFERER"].


I can't really understand why there is no http_referer, how is back
button working on views? Is it possible to implement a general back
action for the cancan access denied exception?


I like the devise approach of "back" method after sign in:
def after_sign_in_path_for(resource)
stored_location_for(resource)
end

It would be perfect if I could combine them.


Thank you!

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



Re: [Rails] Built in (boolean)? method

2011-06-05 Thread Chris Kottom
Sorry, I misunderstood the original message.  Ran similar tests in my local
environment with same Ruby / Rails, and wasn't able to get a similar
outcome.  Is there anything in your model that could be overriding the
dynamically created accessor?

On Sun, Jun 5, 2011 at 9:55 AM, Ants Pants wrote:

> i know about the storage issue (or at least I thought I did) but what I am
> saying is that the returned values are different between the attribute
> for_charity and for_charity?
>
> Surely that has nothing to do with how the values are stored? I sent the
> output form console in my original email to show that.
>
> -ants
>
>
> On 4 June 2011 09:13, Chris Kottom  wrote:
>
>> The actual representation of any attribute type in Rails will depend on
>> the underlying DBMS as the mapping changes from platform to platform.  But
>> if we assume we're talking about SQLite as an example, it uses a SQLite
>> boolean which is actually stored as 0 for FALSE or 1 for TRUE, and both of
>> these are considered "trueish" values by Ruby.
>>
>> On Sat, Jun 4, 2011 at 8:47 AM, Ants Pants wrote:
>>
>>> When creating a boolean attribute in ActiveRecord, you get a ? method for
>>> free. Sadly, it's returning false for a true value. Does anyone know what
>>> might be going on?
>>>
>>> From my console (for_charity: true). Same behaviour on Rails 2.3.8 and
>>> 2.3.11
>>>
>>> ruby-1.8.7-p302 > m.for_charity?
>>>  => false
>>> ruby-1.8.7-p302 > m.for_charity
>>>  => true
>>> ruby-1.8.7-p302 >
>>>
>>> Thx in advance
>>>
>>> -ants
>>>
>>> --
>>> 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+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-talk@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-talk@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-talk@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] Built in (boolean)? method

2011-06-05 Thread Colin Law
On 4 June 2011 07:47, Ants Pants  wrote:
> When creating a boolean attribute in ActiveRecord, you get a ? method for
> free. Sadly, it's returning false for a true value. Does anyone know what
> might be going on?
> From my console (for_charity: true). Same behaviour on Rails 2.3.8 and
> 2.3.11
> ruby-1.8.7-p302 > m.for_charity?
>  => false
> ruby-1.8.7-p302 > m.for_charity
>  => true
> ruby-1.8.7-p302 >

It works ok for me using mysql, could you post the section of
schema.rb for that table?

I have never used the for_charity? syntax though.  There does not seem
much point when it is a boolean.  Is that syntax documented somewhere?

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



Re: [Rails] Built in (boolean)? method

2011-06-05 Thread Ants Pants
i know about the storage issue (or at least I thought I did) but what I am
saying is that the returned values are different between the attribute
for_charity and for_charity?

Surely that has nothing to do with how the values are stored? I sent the
output form console in my original email to show that.

-ants

On 4 June 2011 09:13, Chris Kottom  wrote:

> The actual representation of any attribute type in Rails will depend on the
> underlying DBMS as the mapping changes from platform to platform.  But if we
> assume we're talking about SQLite as an example, it uses a SQLite boolean
> which is actually stored as 0 for FALSE or 1 for TRUE, and both of these are
> considered "trueish" values by Ruby.
>
> On Sat, Jun 4, 2011 at 8:47 AM, Ants Pants wrote:
>
>> When creating a boolean attribute in ActiveRecord, you get a ? method for
>> free. Sadly, it's returning false for a true value. Does anyone know what
>> might be going on?
>>
>> From my console (for_charity: true). Same behaviour on Rails 2.3.8 and
>> 2.3.11
>>
>> ruby-1.8.7-p302 > m.for_charity?
>>  => false
>> ruby-1.8.7-p302 > m.for_charity
>>  => true
>> ruby-1.8.7-p302 >
>>
>> Thx in advance
>>
>> -ants
>>
>> --
>> 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+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-talk@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-talk@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: There must be a more elegant way to do this

2011-06-05 Thread Colin Law
On 5 June 2011 07:45, skt  wrote:
>
>
> On Jun 4, 12:57 am, Colin Law  wrote:
>> On 3 June 2011 17:49, skt  wrote:
>>
>> > Hello,
>>
>> > I have a bunch of arrays containing records retrieved from the
>> > database in separate queries. That can't be changed - I have deal with
>> > the different arrays of these records. Each of these records contains,
>> > amongst other data fields, two ids - a user_id and an address_id.
>>
>> When you say you have arrays are these actual arrays or are they the
>> result of ActiveRecord find queries, which are like arrays but are not
>> actually arrays?
>
> These are result of ActiveRecord queries. I thought they were arrays
> of database record objects - could you please help me understand how
> they are different from normal arrays?

The result of Model.where( some_condition ), for example, is an
ActiveRecord::Relation object rather than an array.  You can for
example apply further .where operations on it to refine the search
further.

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