[Rails] handling errors when separating controllers

2020-03-24 Thread tonypm
A while ago I listened to an interview with DHH where he outlined the 
advantages of using new controllers rather than creating custom actions in 
existing controllers.

I have been trying this approach, and like the way it improves organisation 
and simplifies routes and also encourages scoping/namespacing to group 
resources.

The one thing I have found not too neat is the handling of errors between 
resources.  In particular, if I need to use partials from the original 
resouce (eg to resend the show action), the pathname for the partials are 
wrong since they try to prefix with the alternative controller name.  This 
can be overcome by using absolute paths for partial names.  But this tends 
towards cluttered and brittle code.

Mostly I get over this by using ajax which allows me to render nothng 
inline and just re-display the partial that displays error messages.   
However, I have a products template that includes a form for uploading 
images.  I was doing a rewrite in this area and tried moving the 
create_image method out of products controller and into an images 
controller/resource.

But since the multipart form cannot be remoted, I am stuck with an html 
request.  To display an error message from this action now forces me to 
either redirect (which will reset the page to its initial show state) or 
use absolute pathnames for the partials in the products#show so I can call 
products#show from images#create.  (there are quite a few partials involved)

It occurred to me that this may have been addressed, or that there may be a 
workaround to override the default partial pathname.  

I have tried googling and not come up with very much that helps - I cant 
really think of a succinct phrase to google.

Does anyone have any ideas or suggestions (or am I missing something).

Tonypm


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/1fa26762-956f-4971-af12-ef9ad9d3ee5c%40googlegroups.com.


Re: [Rails] Is there any tool to convet ActiveRecord 2.3.5 statement to sql

2018-04-19 Thread tonypm
For ActiveRecord in Rails 2.3, you can use 

.construct_finder_sql({})

tonypm

On Saturday, 14 April 2018 15:13:15 UTC+1, Hassan Schroeder wrote:
>
> On Fri, Apr 13, 2018 at 10:13 PM, nyt1972 <nyt...@gmail.com > 
> wrote: 
>
> > I want to ask Is there any tool to convet ActiveRecord 2.3.5 statement 
> to 
> > sql? 
>
> If it's a one-time or occasional thing, just execute the statement 
> and grab the query SQL from your logs. 
>
> There are also `to_sql()` methods in ActiveRecord::Relation and 
> ActiveRecord::ConnectionAdapters::DatabaseStatements which 
> (hint) you could find by searching the docs. 
>
> HTH, 
> -- 
> Hassan Schroeder  hassan.s...@gmail.com 
>  
> twitter: @hassan 
> Consulting Availability : Silicon Valley or remote 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/baa4af28-9d4d-42be-b82f-473537327f1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] An application resource called Cables

2017-03-02 Thread tonypm
I have an application which has a resource called cables.  But after 
upgrading to Rails 5.0.1, I can no longer access the cables index page.

in the log I get:

Started GET "/cables" for 127.0.0.1 at 2017-03-02 12:32:04 +
Started GET "/cable/s"[non-WebSocket] for 127.0.0.1 at 2017-03-02 12:32:04 
+
Failed to upgrade to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: 
keep-alive, HTTP_UPGRADE: )
Finished "/cable/s"[non-WebSocket] for 127.0.0.1 at 2017-03-02 12:32:04 
+

Presumably I am getting a conflict with ActionCable routing.

Is there a way to avoid this whilst retaining my own cables resource, or am 
I better off completely moving my resource to another name.


-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/d160c63a-94da-481a-8fbc-23c9e413472a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] categories

2015-11-30 Thread tonypm
Several years ago, I had a similar desire to have a screen representation 
of a category tree.  I was very surprised that I couldn't find any 
pre-baked solution, so I built my own (there may be one out there now of 
which I am unaware).  Unfortunately, I have never got round to making my 
code public, but I can share some of the design considerations I had to 
consider.

1.  What sort of tree would I like - I went for creating something along 
the lines of the windows file explorer - a pretty standard representation.
2.  What elements would this require:
a.  Database - a category structure - ie.  Awesome nested set worked well 
for me.
b.  Visual - simple graphics, small images for: node open, node closed, leaf
c.  Next step was to build  a simple mock up on the screen to create the 
CSS for the tree structure.  HTML struture would be nested ul lists for 
branches and li elements for nodes and leafs.  classes for the open and 
closed state.  (I could share this if you like)

2.  Perhaps the most difficult question is the decision of how much I am 
going to do in JS and how much server side.  I considered supplying the 
whole tree in json format and then using js to build the visual and keep 
things in step.  But it just seemed to get too involved.  And took me more 
into js development than I was comfortable with.

3.  The solution I used was to maintain the tree on the server, and open 
close, create and delete nodes using ajax calls.  Rewriting sections of the 
tree by replacing nodes by rendering appropriate partials.

4.  Giving each node an id of the category model object id allows the 
server to manage the tree by js responses that show/hide branches.

5.  It can seem a bit of a daunting task, but if you break it down into the 
steps above, create open/closed partials that call each other, then build 
the ajax calls for open/close,  it is actually not that hard, and I have a 
working solution that is common across three projects. Rails 2 and Rails 
4.  


Hopefully this at least gives some food for thought.
Tony



On Monday, 23 November 2015 21:13:57 UTC, Colin Law wrote:
>
> On 23 November 2015 at 21:11, fugee ohu  
> wrote: 
> > how to format them on a page ... my thought was to use group_by for 
> > formatting a page that displays all categories 
>
> Do the tutorial. 
>
> Colin 
>
> > 
> > On Monday, November 23, 2015 at 3:39:05 PM UTC-5, Colin Law wrote: 
> >> 
> >> On 23 November 2015 at 20:11, fugee ohu  wrote: 
> >> > I'm looking for a solution for managing categories My categories 
> table 
> >> > has 
> >> > name , parent_id fields My first challenge is to display all 
> categories 
> >> > on a 
> >> > single page and my next is to build select lists represenative of the 
> >> > tree 
> >> > (after this has been done I wanna  integrate listings with them) 
> >> 
> >> I don't understand what is challenging about your first challenge.  Do 
> >> you mean you don't know how to get the categories from the database 
> >> (Category.all) or how to format them on a page or what? 
> >> 
> >> It suggests to me that you have still not followed my and Tamara's 
> >> advice to work right through railstutorial.org.  Until you understand 
> >> the basics you are just wasting your time and ours. 
> >> 
> >> Colin 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Ruby on Rails: Talk" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to rubyonrails-ta...@googlegroups.com . 
> > To post to this group, send email to rubyonra...@googlegroups.com 
> . 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/rubyonrails-talk/145b7f8d-6956-44b3-ac9a-57fecd95e33e%40googlegroups.com.
>  
>
> > 
> > For more options, visit https://groups.google.com/d/optout. 
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/384f64e3-ae98-4ce7-a9d7-b1bda61ec04e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] Re: best way to map fields between rails product and an api client product

2015-03-26 Thread tonypm
Thank you for that, I am still building  the client gem itself, but you did 
prompt me to look around a bit.   Took a look at active resource, and the 
Schema and attributes stuff is going along the path I was looking for.  I 
suspect that I might even be able to make ActiveResource work with the 
Rakuten RMS API, but at the moment I am content to lift some bits from 
ActiveResource, which should also give me the info I need to make the 
errors stuff rails consistent.

I am still not sure how I am going to map from Rails models to my Rakuten 
client models, but I am getting nearer.

Thanks

On Monday, 23 March 2015 17:07:24 UTC, dasibre wrote:

 I'm not completely certain, but I think you might find some insight by 
 looking at ActiveModel

 On Tuesday, March 17, 2015 at 10:14:27 AM UTC-4, tonypm wrote:

 Hi,

 I am working on building an api client for the Rakuten MarketPlace.  I 
 have got some test requests for add delete update etc working and thought I 
 should aim to structure it as a Gem and publish it so that others can use 
 it/enhance it.

 I havn't built a Gem before (worked mostly within the rails environment 
 to date).

 Have been reading and looking at other api client gems and am making 
 progress on building something (still got a way to go to handle errors etc.)

 To make the gem general purpose though, I am trying to figure out the 
 best way to provide the mapping between models in a rails app and  the api 
 client objects (such as product, category, order etc).

 I am aiming to make each client api object a class be  (or should i call 
 them models?) 
 Then I suspect I will use new to build an api instance from a rails 
 instance, and find to return an api instance to a rails instance.

 i can build in mapping for my own models to the api objects with no 
 problem, but I can't see how I could generalize this so that other apps 
 with similar models could use the gem.

 I suspect there are approaches for doing this, but so far I haven't 
 managed to come up with how to do it.  If anyone has any wisdom on the 
 matter I would be grateful.

 Tony Martin



-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/2d67d0c0-a733-439f-9ecc-a4d668bcd049%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Rails] best way to map fields between rails product and an api client product

2015-03-17 Thread tonypm
Hi,

I am working on building an api client for the Rakuten MarketPlace.  I have 
got some test requests for add delete update etc working and thought I 
should aim to structure it as a Gem and publish it so that others can use 
it/enhance it.

I havn't built a Gem before (worked mostly within the rails environment to 
date).

Have been reading and looking at other api client gems and am making 
progress on building something (still got a way to go to handle errors etc.)

To make the gem general purpose though, I am trying to figure out the best 
way to provide the mapping between models in a rails app and  the api 
client objects (such as product, category, order etc).

I am aiming to make each client api object a class be  (or should i call 
them models?) 
Then I suspect I will use new to build an api instance from a rails 
instance, and find to return an api instance to a rails instance.

i can build in mapping for my own models to the api objects with no 
problem, but I can't see how I could generalize this so that other apps 
with similar models could use the gem.

I suspect there are approaches for doing this, but so far I haven't managed 
to come up with how to do it.  If anyone has any wisdom on the matter I 
would be grateful.

Tony Martin

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/6f43c051-578a-4e26-9e48-7d40af5541c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails] Updating Rails 2 to Rails 3 or 4

2014-07-14 Thread tonypm
Rob, this is a useful summary,  Thanks.

I face the same problem, having two large apps that are in constant 
development and so without putting a stop to development and focusing on 
upgrading (something that would be very hard to sell to one of my clients), 
I am strugling to see a way forward.  I have got to 2.3.18, and have been 
looking at when to upgrade Ruby, and keeping the right version of gems and 
rubygems seems to also be a challenge along the way.

For me at the moment, the greatest hurdle seems to be when I need to go to 
the asset pipeline in 3.1.  Your summary identifies that - thanks.  I am 
also using Prototype js, and am wondering whether I should migrate to 
JQuery along the way, or get as far as possible with Prototype.  There is 
not masses of js, but enough to make me wonder.  I have done some work on 
3.1 with JQuery, but it could take some effort to implement that in my 
current codebase, and I get the sense that things will look quite different 
with the js at Rails 4 anyway.

In giving this ongoing thought,  I have been wondering if it would be 
possible to upgrade my apps in sections, by breaking them into separate 
functional areas, and making them separate apps (perhaps on separate 
servers).  My thinking being that this might make it possible to upgrade 
each section in turn (re-writing straight into Rails 4) and so break the 
workload down.  I have one section that handles mostly scheduled 
maintenance and this is a clear candidate. I would have to mirror the 
models, which might become very cumbersome though.

I haven't got very far with this thinking, and would be interested if 
anyone has any thoughts.  Another main issue that I can see is the need to 
provide consistent login when a user moves between the apps, but I think 
this should be achievable.

I have also seen some stuff written about using engines to help to break an 
app down into more manageable and separate parts and have thought that this 
might also be worth looking into at the same time.

Doing the upgrade in parts would also make it easier to ensure the parts 
being upgraded do have up to date tests.

I would be interested on any wisdom from others who have already trodden 
this path.


Thanks
tonypm


On Thursday, 3 July 2014 20:54:59 UTC+1, Rob Biedenharn wrote:


 On 2014-Jul-3, at 15:49 , Rob Biedenharn r...@agileconsultingllc.com 
 javascript: wrote:


 On 2014-Jul-3, at 11:25 , Jason Fleetwood-Boldt te...@datatravels.com 
 javascript: wrote:

 As was suggested to you by other posters, please read the upgrade guide 
 carefully (here is the official one 
 http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html) 

 it is recommended that you have very good test coverage before you begin. 

 I suggest you use a tool like simple-cov to make sure all your lines of 
 code are tested before you begin, as well I'd recommend integration 
 coverage for every major end-user happy path through your app. 

 When you are sure you have complete test coverage, change the version in 
 the Gemfile and then run bundle update rails


 On Jul 3, 2014, at 10:28 AM, M,Gopi M.gopinath gopi1...@gmail.com 
 javascript: wrote:

 Hi,
   Seems I need to say this first, The website which I 
 have Know is 8 Years old website, Developed in Ruby 1.8.6 and Rails 2.3.6, 
 and its as 220 tables in it and lot of controllers and views. Is there a 
 way to update this to current version of rails and ruby. 


 The short answer is yes, but it is certainly not easy, nor can you make a 
 single leap.

 Simple-cov will not help you yet as it requires ruby 1.9.3 or better. 
 (It's been so long that I can't even remember if there was a similar tool 
 that worked with ruby 1.8.6.)

 You may find it simpler to write a new app from scratch, importing (by the 
 time-honored cut-and-paste method) the important bits of business logic.

 However, if you want to proceed with an upgrade, this is roughly what 
 you'd need to do:

 • update to rails-2.3.18
 There's really no reason not to and PLENTY of good reasons that you should 
 have done this already.
 2.3.9 (2010-09-04) was the version that first gave deprecation warnings 
 for the upgrade to rails-3.0
 2.3.18 (2013-03-18) was the last releast in the 2.3 line and contains 
 fixes for at least 10 vulnerabilities (some of them quite serious!)

 • get all your tests to pass (if you don't *have* tests, you'd better have 
 faith)
 • address all the deprecation warnings

 • don't upgrade ruby yet

 https://developer.uservoice.com/blog/2012/03/04/how-to-upgrade-a-rails-2-3-app-to-ruby-1-9-3/
 But you might have to upgrade to ruby-1.8.7 as rails-3.0 doesn't 
 officially support 1.8.6)


 Oh, and I took a look at 
 http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html as 
 suggested by Jason Fleetwood-Boldt and that has a MUCH more detailed walk 
 though the upgrade process from 3.0 to 4.1. But if you don't have time to 
 go and look at that yourself, then perhaps I've

[Rails] Re: accessing the changed? method for an overridden attribute - sorry - non question

2013-08-10 Thread tonypm
On Friday, 9 August 2013 18:04:54 UTC+1, tonypm wrote:

 I am using rails 2.3, and have overridden an attribute.

 I am building a before_save callback, and would like to check if the 
 attribute has changed - but can't figure out a way to do this. 



Sorry - silly Friday afternoon question.  changed? method applies to the 
object as a whole, to test if an attribute has changed, should have used 
attrname_changed?  which of course hasn't been overridden.

 

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/058af936-2bce-4ce9-a61a-01b6502764fc%40googlegroups.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


[Rails] accessing the changed? method for an overridden attribute

2013-08-09 Thread tonypm
I am using rails 2.3, and have overridden an attribute.

I am building a before_save callback, and would like to check if the 
attribute has changed - but can't figure out a way to do this. 


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/edef158e-70a3-4aea-80dd-c18b7a2eb3da%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: How to create 10000 pseudo data for Testing in RoR

2013-04-14 Thread tonypm
One approach may be to build the data as a large csv.  Which you could do 
from ruby if you wished and you can then keep as a file.  Then either 
import directly to the db with sql or workbench etc. or if you want to stay 
ruby, load the csv and use ar_extension import to  dump the data into the 
db.


On Friday, 5 April 2013 16:08:04 UTC+1, Ruby-Forum.com User wrote:

 I want to test performance of project. 
 So i want make 1 record of table for testing. 
 I don't know how to ganerate record. 
 Who can help me? Thanks. 

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


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/sZheFpnQ2wkJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Best IDEs for Ruby on Rails

2013-03-19 Thread tonypm
Redcar completely suits me as a free highlighting editor with a good file 
browser and multiple display tabs and side by side editing.



On Saturday, 16 March 2013 04:40:37 UTC, Jason Hsu, Android developer wrote:

 What are your favorite IDEs for Ruby on Rails?  Are there any good IDEs 
 that IMMEDIATELY flag problems the way Eclipse does in Android 
 development?  Given the importance of testing, I'd like to use a tool that 
 immediately and automatically flags problems.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/3Oo4eyUfea0J.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: [ANN] Ruby Manor 4, London UK, 6th April 2013

2013-01-26 Thread tonypm

fist I've heard of it again this year.   What secret society do you need to 
belong to to get a ticket - lol


 We'd love to see you there.

*I'd love to be there!*

In anticipation
Tony


On Tuesday, 22 January 2013 16:22:34 UTC, James Adam wrote:

 There's a good chance you've already seen this, but just in case not...

 Tickets for Ruby Manor 4 are now available, happening on the 6th of April 
 2013 in London, UK.

 Full details and ticket info: http://rubymanor.org/4/



 All the best,

 - James


-- 
You received 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.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/cHk58MeD5yUJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] -bash: ruby: command not found

2012-11-03 Thread tonypm
This guide pretty much worked for me as i recall.

http://library.linode.com/frameworks/ruby-on-rails-nginx/centos-5

On Thursday, 1 November 2012 16:00:59 UTC, Norbert Melzer wrote:

 2012/11/1 keerthi priya emailtoke...@gmail.com javascript:: 
  Thanks Norbert. i have installed ror on cen os . i can help me out for 
 Nginx 
  with passenger on CentOs plz... go process to install Nginx with 
 passenger. 
  i have installed but i have some problem what i have installed. 

 Sorry, but I can't help you with nginx, I had to use apache. 

 But that other people can help you, you should provide some more 
 information what exactly isn't working. 

 If it is nginx in general you should probably ask on a nginx or centOS 
 list first. 

 If it is passenger, tell what you have tried and what errormessages you 
 get. 


-- 
You received 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.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/txhjGQZL-vQJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Rendering a partial with ajax/jquery

2012-10-31 Thread tonypm
From the question you have posed, and the information you have provided, 
there is not a simple 'do this' answer.  You need to get a bit further down 
the path of what you want to achieve.  (unless someone knows some magic foo 
that I am unaware of).

Looking at what you have so far, it would seem that you have the basic 
functionality of the page, and you have an idea of what you want to 
achieve, but you do not yet appear to have a strategy or plan for how you 
are going to achieve it.  I have never implemented continuous scroll, but 
giving it some cursory thought, I would begin by asking myself some 
questions.

1.  How is the page update going to take place when I extend the contents.  
 eg.  - replace the whole page each time the list updates
or -  replace the list section 
or - add additional items at the end
 Do I let the page size continue to grow indefinitely or do I remove 
some items from the other end.

2.  If I am going to manage addition/deletion of items.  The items will 
probably be best structured in an an html list or table, and each may need 
a unique id, or can I just append/prepend  to the list of items.

3. What mechanism will I use to identify the next 'page' of items I want to 
add to the list.

4.  How is my controller going to get the correct list of items to add? ie 
what paging mechanism am I using.

5.  How am I going to handle the ajax response that contains the items.  I 
am going to need some js code to append/prepend or insert the items into 
the list.  

6.  What form will my response be in.  I can send some javascript using an 
erb template to insert the items, or I could have a js function on the 
browser side ready to handle the response (eg as a success callback 
handler.)  Or I could return data as json and handle the paging more fully 
in the browser js.

7.  Finally having thought about all this, I would do some googling to see 
if someone has already implemented such a thing in a form I could learn 
from, or is there maybe a js library that might already provide most of the 
functionality I require.  

I am sorry this is not a direct answer, but hopefully it may help to 
clarify what you are trying to achieve and how you are going to go about it.


Tonypm
 


On Monday, 29 October 2012 23:05:43 UTC, Ruby-Forum.com User wrote:

 Hi there i have this issue I have a view that render a partial for each 
 member inside the object @foo and I have a function for infinite scroll 
 so the server will be doing request after request while scrolling down 
 but I don't know exactly how to make this work here is some of my code: 


 def popular 
 @foo = Foo.new 

 respond_to do |format| 
   response = @foo.popular 
   ... 

 flash[:notice] = Welcome. 
 format.html { render popular_foo_path} 
    
   end 
 end 
   end 

 views/foo/popular 

 - @foo.each do |f| 
 = render(:partial = popular_foo, :locals = { :foo = f}) 

 views/foo/_popular_foo 

 - f['thumbs'].each do |thumb| 
 = image_tag(thumb['thumburl'].to_s, :alt = thumb, :class = 
 thumb-popular) 

 every time you scrolldown to certain height a fuction 
 $(document).infinite_scroll is called and i have it configured to make a 
 new call to the method popular and I can see in the console and in the 
 firebug that it do the request and succeed but it won't render the next 
 results. 

 -- 
 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/DNjP5tChIy4J.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: How to use Ajax with rails ?

2012-10-30 Thread tonypm
I have just been reading this and finding it helpful background with
some nice examples:

http://madebydna.com/all/code/2011/12/05/ajax-in-rails-3.html


On Oct 29, 10:41 am, 1334 i...@sipspp.net wrote:
 On Friday, October 26, 2012 5:38:20 PM UTC+2, Fahim Patel wrote:

  Hi all,

     Can any one tell me how to use Ajax with Rails.
      Send me quick start up link and videos.

  Thanks

  Regards
  Fahim Babar PAtel

 it's still in edgeguides but it's a nice intro written by @steveklabnik (if
 i'm not 
 mistaken)http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html

 cheers

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




[Rails] Re: IDE

2012-10-10 Thread tonypm
I switched to Redcar a while ago and whilst not the fastest tool out of the 
box, it is actually pretty good.  

Being still in development, it still has a few bugs.  It can be a bit 
fiddly to set up since it needs a java runtime.  It is a bit slow on 
startup, and can lose track of which window has the focus.

Code highlighting is pretty good, covers rails syntax families pretty well, 
has auto indent, and I do like the multipane feature and rectangle block 
copy. File navigator is not bad too.   I am pretty happy with it.


On Wednesday, 3 October 2012 18:33:30 UTC+1, Avi wrote:

 Hello,

 What is the best IDE for ROR with JRuby,
 Currently I am using Aptana Studio. I am trying to use Rubymine.
 Which IDE would give better support to debugging ?
 Any Suggestions?

 Is there any problem to keep both JRuby  ruby versions ?


 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.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/1BRhgrFYwZcJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Which Framework will improve my Ruby Skills?

2012-09-04 Thread tonypm

What I actually find most important is being able to do a well worded 
google search (I sometimes wonder if there should be a qualification for 
that in itself lol?).  The Ruby and the Rails forums are very friendly and 
helpful.  

I usually start a google search with Ruby or Rails and the version number, 
followed by a question that tries to avoid using common phrases. 

Finding a past thread relating to something you are trying to achieve can 
very often lead to an excellent discussion with different approaches to 
doing things.   I nearly always find someone has written something worth 
reading.

How you go about learning, also depends on your main goal.  Is it to get an 
app up and running, or is it to become more proficient as a programmer (I 
am guessing probably some of both)

Occasionally digging into some existing code can highlight areas where you 
may want to improve your understanding.  Particularly when thinking about 
how to structure a program. 

If you want to learn Ruby, then any Ruby based framework is likely to help, 
although I only have experience of Rails.  What I do think is that Rails 
opinionated approach can help you to formulate some good approaches to your 
own development.


Using a framework is a great way to build an app, but may not be the best 
way to get to understand how to develop in an object orientated way.  For 
this, following the tutorial in the Ruby Book, is a start.  What I found 
great fun and very challenging was developing a small app using GTK2 and 
Ruby.  With GTK you can build a small window based app, although getting 
your head around the API can be a bit challenging.  But starting something 
from scratch is useful to get to understand how to structure your folders, 
where to put your code and how to define and build objects etc.

Just my thoughts!



On Sunday, 2 September 2012 15:06:24 UTC+1, ACK wrote:

 thats the best advice i have ever got = Thanks

 On Sun, Sep 2, 2012 at 7:27 PM, Peter Hickman 
 peterhi...@googlemail.comjavascript:
  wrote:

 Programming in Ruby will improve your Ruby skills.

 Work on non trivial projects that involve things that you have not
 done before and see them through to completion. This way you will gain
 experience and hone your skills. Reflect upon the quality of your
 work. Criticise your own work. Find your own mistakes and learn from
 them.

 There is no shortcut.

 Having said that just sticking to what you know and not venturing
 beyond your comfort zone will result in little growth despite how much
 effort you put in to it.

 --
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to 
 rubyonra...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 rubyonrails-ta...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.





-- 
You received 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.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/4uMqbB6QxlEJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Ruby Koans

2011-09-13 Thread tonypm
Just started going through - it is nice - thanks for the info!

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Rich text editor?

2011-04-20 Thread tonypm
Correction,  just checked and doesn't look like I used a plugin so
can't say how good plugin is!

On Apr 20, 8:24 am, tonypm tonypmar...@hotmail.com wrote:
 I have used CKEditor for some time with no problems,  I have one page
 with several editor instances and it works fine.

 There is a rails pluginhttps://github.com/standout/rails-ckeditor
 I think this is the one I used

 Tony

-- 
You received 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: model with no primary key

2011-03-18 Thread tonypm


On Mar 17, 11:04 am, Frederick Cheung frederick.che...@gmail.com
wrote:
 Could you just tell rails that categories_id is the primary key? If
 it's unique then that should be good enough (you'll probably have to
 be a little careful when creating rows in this table though, as you'll
 need to set categories_id each time)


You are quite right Fred.  I think I must have confused myself.  I
initially tried to bulk assign using create, but this resulted in the
categories id not getting set.  I thought i had tried using new and
setting the categories_id before saving, but I must have confused
myself.  I have just tried it again and it works.

Many 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] model with no primary key

2011-03-17 Thread tonypm
Hi,

I have looked around quite a bit, and haven't found any workable
solution to this.


I am accessing an external/remote database from my rails app, in order
to update a categories table.

I cannot change the table structure of the remote database.  it has a
categories table with an id field but has a one to one relationship
with a descriptions table.

The descriptions table has no primary key, only a categories_id.

Setting up a one-to-one relationship in my model allows me to load the
description along with the category.  But I need to be able to create
a new category and description and cannot find a way around creating
an ActiveRecord object without a primary key.

Grateful for any suggestion of how to do this.  I am wondering if I
can use sql from within the model, but not quite sure how this would
be done.

Tony

-- 
You received 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: Which editor to use

2011-02-18 Thread tonypm
It is funny.  The last time I followed a long thread about rails
editors, the enthusiasm seemed to be for emacs.  So I installed it and
got used to it.  It has some very good features, the first time I
installed it I had trouble setting up the packages I needed for rails/
haml etc.  But recently when I reinstalled my system, I discovered the
package manager, which makes that very simple.  The ability to have
several panes open and switch between them is really handy.  Emacs
also offers support for some rails functions like migrations etc.

However, I do still struggle with remembering the key sequences.

The emphasis in this current thread seems to be towards Vim.  I did
try that some time ago and never really got it set up to do
highlighting correctly, (I do use vi quite a bit for simple file
editing on my linux boxes).  Mostly what I want from an editor is good
highlighting, fast response and good indenting support.

More recently, I saw Redcar mentioned and decided to give it a try.
It seems very promising.  It handles highlighting well, but does lose
track quite easily.  It was quite a large (although simple enough) gem
install process.  It has a long start up time too, and does as
mentioned use a fair amount of resource.  But as also mentioned, it is
very young, and hopefully it will continually improve.  I am sticking
with it for the moment, but must say I am missing the emacs multi-pane
display.  On the plus side, though the page/window presentation of
Redcar just seems cleaner.

It is a fascinating subject.  I wonder what research has been done
about what is important in a development editor.  To me the visual
presentation is actually quite important to help me stay focussed on
what I am doing and where I am working in the file system.  It is
quite hard to actually put my finger on what makes me comfortable.  I
always found Netbeans made me feel like I was 'doing' ruby on rails
development - it sort of created a context.  But it is just too
overweight, and I was quite pleased to switch to emacs.  Emacs can
also help to give a feel of context, but I found it took a bit of
effort to grasp it, and sometimes I have to stop thinking about what I
am developing to figure out a key sequence I need eg for search etc.
I suppose on reflection, for me, the most important criteria is, what
editor allows me to just focus fully on the code I am writing without
being distracted by the editor itself.


Tony

-- 
You received 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: Is Ruby on Rails for beginner programmers?

2010-10-23 Thread tonypm
Etilyeti


 I am pretty good with HTML, and I know a bit of PHP and MySQL.
 I was about to plunge my head in my big PHP/MySQL book when I realized
 that it may not be the best programing language to learn.
 Would you recommend Rails for beginners?
 If not, what language would you recommend?

 Thanks a lot in advance.


I think this thread got a bit hijacked on some slightly esoteric
issues.  Hopefully this didn't put you off.

I would say Ruby is a great place to start.  There is loads of really
good stuff on the web that will lead you into good programming
practices (I think Marnen said that too).  Also it is a beautiful
language in terms of readability.  It is not a long way from Visual
Basic in a superficial readability and scripting sense, but is much
more in terms of being a fundamentally well designed Object Oriented
language.  The thing I found tricky at the beginning was working out
the distinction between what was Rails and what was Ruby, but it soon
falls into place. Also you need to get used to using the API
documentation. But again that falls into place too.  There are now the
RailsGuides which are excellent.  http://guides.rubyonrails.org/

I actually started with a quick Rails Tutorial, and then adapted some
stuff I had done in MS access/visual basic into a Rails project under
windows.  I produced some  not very elegant code to begin with, but
hey some of that code is still in use after nearly 5 years - I am
trying to find time to refactor it now.   Whilst Marnen is correct in
referring to test-first development, the problem with this is that it
can be a massive subject, which in my view makes getting started very
hard.  I havn't looked lately, but I never really found any good
tutorials that start with test (or at a higher level, behaviour)
driven development.  So learning to do TDD or BDD is important, but
don't le it put you off learning Ruby in the first place.  Maybe
someone could suggest some tutorials.

It is very easy to play around with Ruby in a shell (irb) and do the
hello world type of stuff, and using the rubygems library makes doing
more complex stuff a breeze.  There are not loads of things to bolt
together to get your first progams to work.  You can even try the
Interactive Ruby Shell online at http://tryruby.org/.

Writing an actual program is nothing more than creating a text file
and running it under Ruby.   And when you want to do something
specific, there is nearly always a Ruby gem to help you out so that
you don't have to re-invent the wheel - whether it is accessing
databases, scraping web pages, manipulating images or creating pdfs.
Just install the Gem (one line command like 'gem install pdf-
reader' ) , require it into your program and away you go.

As already stated, there are some drawbacks to using Windows, but they
are not show-stoppers.  And anyway, it is not that hard these days to
set up a Linux system (I use Fedora)

As you can probably gather - I am extremely enthusiastic about Ruby
and Rails.  They have allowed me to develop systems for which I was
struggling to find a cost effective solution.  My biggest uncertainty
initially was would rails become cumbersome or fall apart as I
extended my systems.  In fact the opposite has been true.  The
framework really holds together as your system develops and evolves.
There was loads of talk about such things in the early days, but now
it is pretty much just taken for granted.  Something that used to
amaze me was that when I added some functionality into my code, the
number of program lines actually went down, because adding the new
function often resulted in me doing things in a better or more
efficient/effective way.  Again these days I take such things for
granted, although I do still find occasions when for example, I
produce a nice object that builds a super report, or I manage to
create a nice object oriented structure to something I am trying to
solve.

hope this encourages you
Tonypm


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



[Rails] Re: Formatting Names and Addresses

2010-10-18 Thread tonypm


 Would the Snail gem help?


Thanks Marnen, looks like it may be of use, or at least a starting
point.
I'll play with it and see


Thanks
Tonypm

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



[Rails] Formatting Names and Addresses

2010-10-14 Thread tonypm
I have to import names and addresses that have already been created
without any validation.

Does anyone know if there exists a standard/utility/bit of code etc
that does the formatting automatically.  Using titleize is a start,
but there are obviously lots of additional formatting requirements
such as Initials in caps etc.

I know this is not strictly Rails, but it is for a rails project and I
couldn't think of another forum that I could pose this question on.

Tonypm

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



[Rails] Re: How old are you?

2010-10-12 Thread tonypm
I don't mind admitting I am 54 - I am aiming to keep learning and
developing my skills as long as I can.  I am self employed working on
my own, so this forum is a lifeline to keeping in touch with what is
developing and picking up on how to do things better.  I always find
it helpful when concepts are discussed and appreciate links to useful
resources.  (thanks to those who contribute)

Finding time to keep up with changes as well as doing actual
development is quite a stretch.

Tonypm

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



[Rails] Re: free ruby on rails hosting?

2010-10-06 Thread tonypm

 Forums are here for people to ask questions.

 Now you look like a douche every time someone searches for free RoR
 hosting.


Actually, I would have said that the forums were for people to get
answers, not much point asking a question if no-one is going to
provide a useful answer.

I have found most of my questions answered by searching the forum and
looking at responses to previous questions - so that mostly I have not
had to ask the question myself.  In fact I learned to use ruby on
rails that way .

This forum used to excel in a) the quality of responses, depth and
helpfulness AND b) politeness and patience.

Sadly these things seem to be getting eroded.  It would be nice if we
could keep to being polite and user friendly and provide responses
that have useful content.  Remember, if you give a helpful answer, you
haven't solved just a single user's query, you have provided
documentation for many others when the search the forum in the
future.  If you can't resist saying read the docs or it has been
answered in another post, then at least have the decency to point to
the post or reference with a proper link - otherwise wouldn't it just
be better to say nothing.

I have been feeling these things for several weeks now, and my
disappointment in the rails community has been growing.  This post
just tipped the balance so I felt I had to make a comment.

with very best intentions
Tonypm

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



[Rails] Re: Need an online payment system - suggestions required

2010-09-11 Thread tonypm


On Sep 6, 3:52 am, Christian Fazzini christian.fazz...@gmail.com
wrote:
 Hello all,

 We are about to launch our site. One of the features that is missing
 at the moment is a way for users to fill in their credit card details
 and click send to purchase our products that we offer on our website.

 We are relatively new to this concept, so we do not know where to
 start? I am guessing we have to open up a merchant account? Is this
 the right term? Or Is it an online gateway payment system?

 So far, I've come across the following: Braintree, PaySimple,
 TrustCommerce, BeanStream, Shopify, Authorize.net

 Ive also come across a plugin called ActiveMerchant, which, I assume
 handles the interface to send data to whichever merchant account I end
 up signing with. Is this correct?

 What should I look for when considering one of the above services?
 Fees? Processing fee per transaction? Monthly billings, etc?

 Any additional information will be appreciated.


This question interests me too.  Strange not to have got any response
to this- I wonder how many people have actually implemented a payment
gateway on a rails site  - it doesn't seem to appear in posts lately..

Tonypm

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



[Rails] Re: File creation in Rails

2010-08-03 Thread tonypm
To access files in rails, you can use the Ruby File Class

http://ruby-doc.org/core/classes/File.html#M002579

You can put this into a method in the model.  Then either call it
specifically from the controller, or use an after_update callback to
automatically create the file after the object has been saved to the
database

def save_file(filename)
   File.open #{RAILS_ROOT}/tmp/#{filename}, 'w' do |f|
  f.write contents
   end
end

Tonypm

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



[Rails] Re: ajax and redirect

2010-06-09 Thread tonypm
With my search forms, I use two partials, one for the controls and one
for the result and then just use a page update to redisplay both
parts.

If you really want a redirect



On Jun 6, 11:25 am, javinto jan.javi...@gmail.com wrote:

 format.js {
           render :action= search_show, :layout=false
         }

javinto,
Interesting, something I  have not tried.  Is this an ajax update
response, in which case, the part of the dom being updated would
presumably need to be the part generated by the yield in the layout?

badnaam
I use ajax search forms and handle the update as two partials, one for
the controls and one for the results, using
render :update

Tonypm

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



[Rails] Re: Can a dropdown be used to select additional form fi

2010-06-09 Thread tonypm
Steve,

When you reload/refresh the page, the browser remembers some of the
current state of the page, so that a browser refresh is not the same
as loading the page again - ie by resubmitting the url (which best
simulates the effect you see after a validation error).  It is easy to
get fooled with this especially if you have js functions on the page.

In order to make sure the correct form/partial is redisplayed, you
will need to make sure that information about which partial is
currently displayed is available to the server in some way.  In your
case, that is going to be the value of the select control returned in
the params hash which will need to control the creation of the page by
setting the right partial to be displayed.

Because you are showing/hiding the partials, then a way to do this is
to not use a js function to set them to not display, but to do it
using css styles which you can set up when the page is displayed.   A
little bit of logic in the page redisplay can then determine which
partial should be displayed based on the params value of your select
box.

My personal preference to meet your needs would be to use the solution
suggested by Bill, to use an observer on the select which would cause
the required partial to be displayed.  Using this approach keeps the
server in control of what is being displayed.

Tonypm

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



[Rails] Re: One Array - 3 Columns of Equal Length

2010-05-31 Thread tonypm
in_groups   and in_groups_of

part of rails api - hadn't spotted those before and would never have
thought of looking for them.
I often wonder how many other useful little goodies I may be missing.
Always useful to keep an eye on this group.


thanks Marnen

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



[Rails] Re: Rails default date format

2010-05-23 Thread tonypm
There is also

validates_date_time plugin

http://agilewebdevelopment.com/plugins/validates_date_time

if you also want to allow entry in other formats

Tonypm

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



[Rails] Re: Ubuntu Linux Editor / Prettiefier

2010-05-03 Thread tonypm


 Normal?  What makes them any more or less normal?


i just knew someone would pick up on that comment!!   I added in
Windows to clarify, but re reading what I wrote, I should have said
cut and paste buffer keystrokes, which is what I think was
predominantly in my mind.  The reason I stuck with the wording normal,
was that it occurred to me these were not just windows keystrokes but
the keystrokes used by  most web browsers, which these days IMHO makes
them pretty much the norm.

But what the heck - I am getting better with emacs all the time,
running the console in one of the buffers is working well, and
switching between buffers to re run commands etc is now becoming much
more automatic.  I just need to learn to resist the temptation to pick
up the mouse!

Tonypm

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



[Rails] Re: Ubuntu Linux Editor / Prettiefier

2010-04-27 Thread tonypm

 1) Move the cursor to the start of the text you want to select.
 2) Set a starting mark using Ctrl + Space.
 3) Move the cursor to the end of the text you want to select.
 4) Copy the text using Alt + w, or cut the text using Ctrl + w.
 5) Move the cursor to wherever.
 6) Ctrl + y to paste.

Thanks Greg that is perfect - somehow I had completely missed that.  I
notice now that the tutorial describes C-w but does not mention M-w

Tonypm

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



[Rails] Re: Ubuntu Linux Editor / Prettiefier

2010-04-27 Thread tonypm

 I switch buffers using the arrow keys most of the time.

 Ctrl + x, and then left or right arrow.

Thanks that helps (I notice you can also left and right click on the
buffer name in the status bar)

Tonypm

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



[Rails] Re: Ubuntu Linux Editor / Prettiefier

2010-04-27 Thread tonypm
Marnen

Thanks for your comments

 Ah, good point.  Emacs is my favorite console editor, but I'm not all
 that crazy about the graphical versions I've tried.

Actually, I use Fedora, and installed the gnome version of emacs, so I
do have the graphical console, but your comment about learning the
keystrokes is valid.  When you've been used to the normal windows
style keystrokes, the emacs  ones take a bit of getting used to.  But
I am getting there by forcing myself to use it for my real
development.  I am already beginning to feel more comfortable.

 NetBeans is an excellent IDE, but it's overkill for Rails.  (I'd be
 curious to know about it's sluggishness, though -- it has consistently
 been pretty fast for me on Snow Leopard.)
I do like NetBeans, but I found it is hungry on resource, and I notice
a distinct delay when browsing the file tree or opening a file etc.
Also, the auto suggest popup boxes keep coming on.  I turn them off
but they reappear.  I find that annoying because they frequently pop
up just as I have finished entering a line, and their appearance
causes a delay whilst they are escaped.  I may be missing a setting
somewhere to turn them off.  For portability, I actually use a small
machine for development, which is probably why NB feels a bit slow.

 Then I'd almost say you shouldn't use Emacs.  You definitely have to be
 comfortable with keyboard commands to get the most out of it.
I already make good use of filename auto complete in the linux shell
and am finding using that for locating files is good.  I have figured
out that using partial complete brings up a list of filenames for
selection and I am getting to really like that.


   Syntax highlighting is great

 Any better than in other editors?
Not necessarily better, but haml and sass highlighting is available
which is not true for all other editors (I actually like bluefish a
lot, but I havn't found a haml/sass option).  Flagging of syntax
errors seems pretty good too.


 You might want to investigate a GUI version of Emacs, then.  I don't
 like the ones I've tried, but you might.
The Gnome emacs has a Buffers command in the menu which is great, but
I get a 2 second delay between clicking a command and the menu
appearing.  Also, I do a lot of work across vpn to my sites, so I want
to force myself to learn the keystrokes rather than depend on the
menu.  I have to admit to using the menu cut and paste quite a bit.  I
haven't yet mastered doing this easily with keystrokes (i know there
is a way of switching emacs to use the standard cut and paste
keystrokes, but it seemed that doing that would interfere with other
emacs commands so I haven't tried it - perhaps I should).
I do like the ability to operate on a rectangle of text though, on
some occasions this can be useful.


 IMHO, so does KomodoEdit.  Actually, Emacs coming close to [TextMate]
 is a funny statement: Emacs is probably the more powerful of the two.

I havn't used Textmate, so I was really only commenting on what I had
read.



The two areas I want to start to get to grips with now are auto
formatting and text snippets, but where do I find the info for them?
eg what is the correct way to create a new def.  With NB, when you
start a def, the end is often created automatically with correct
indentation.  How can I do that in emacs?



 C-k, C-y, C-y.  There may be a faster way.  If you don't know this, you
 *really* need to spend time on Emacs basics.
I have started using this sequence, it just seemed a bit odd to remove
something first to replace it twice but after a while you don't even
notice.


Tonypm

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



[Rails] Re: Ubuntu Linux Editor / Prettiefier

2010-04-23 Thread tonypm
Interesting that no one hs yet mentioned emacs. I decided the other
day to give it a go since so many posters had raved about it and
Netbeans sluggishness was frustrating me.

Well I have to say it has been hard work getting into emacs.  I can
just about use the editor, and after a fair bit of fiddling, googling
and reading, I have rinari installed from ELPA and also emacs-rails.

Got the speedbar working for rails files - necessary for my transition
since I am finding grasping all the keyboard command sequences very
hard.

The biggest hurdle seems to be finding out exactly what can do with
it.  Syntax highlighting is great and being able to directly open
views from being in a controller action etc is great, but all the
other stuff seems a million miles away.

Although I am finding it difficult I intend to persevere, the thing I
feel that is slowing me down at the moment is switching between
buffers when working with multiple source files.

I have never done much with auto completion or snippets even with
Netbeans, but suspect that there is performance gain just waiting to
be harvested.  I am envious when I watch Ryan Bates editing code he
zips around so elegantly (I know that is Textmate but emacs is
supposed to come close to it)

There are some screencasts around for emacs and rails, but they have
no sound and the casters seem to forget that they are dealing with
novices and screens flash around with invsible keystrokes in a way
that makes my head hurt.  Nevertheless they do give an overview of
what is possible.

I havn't yet found a quick way to duplicate a line or series of lines
eg alt+ctl+down arrow in netbeans - if anyone can enlighen me I would
be grateful.

Tonypm

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



[Rails] Re: api.rubyonrails.org site is taken over by a domain squatter

2010-04-22 Thread tonypm
Thanks - it may have only been a short time, but I was missing the
guides.

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



[Rails] firefox 3.6 not caching css and js files

2010-04-21 Thread tonypm
I have an in house app that has been running for several years, with
regular enhancements.  Just recently I have noticed that on windows
clients, firefox 3.6 is no longer caching any css or js pages.

Watching the pages load in firebug, they are all showing as :
304 Not modified
but are re-loading anyway.  This does not happen with IE or firefox on
linux or mac.

But firefox seems to be ok with other web sites, so I still have to
suspect something with my setup, but don't really know what to look
for.


Tonypm

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



[Rails] Re: regular expression

2010-03-31 Thread tonypm
Interesting to see two regexperts slogging it out  :)

Seriously though, I have to confess I have a real block when it comes
to regexp.  There seem to be so many variants of ways of doing
things.  This example is the sort of thing I have done in the past,
but never so elegantly.  Trouble is I am not entirely sure what is
going on in this syntax.  I wonder if one of the two bright guys here
could help with a little explanation of for example:

a.  the square brackets causing the match?
b.  the 1
c.  look ahead?
d.  why does the 1 return block without the $

I would really like to get my head around this stuff.  If you know of
a good tutorial/guide that would be helpful too.  The problem I find
is that so many of the guides go over the same basic stuff, I seem to
read loads of things and never get to the real meaty bits, or the
explanation of the meaty bits then goes over my head.  I don't mind
admitting to being dumb!

Thanks
Tonypm

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



[Rails] Re: Trying to create search filter persistence using SearchLogic

2010-03-16 Thread tonypm
I have done something along these lines using a database store.  I
dont use SearchLogic, but build my searches using anonymous scope and
also use Thinking Sphinx.

I have a search model with attributes as below:

Where the search was made from:
t.string  user
t.string  model_name
t.string  controller
Details of the search
t.textsearch_filter
t.string  search_type
t.string  search_field
t.integer page
t.integer per_page
t.string  name

user holds the id for the user making this search.
search_filter contains the search fields serialized, so it can save
fields for searches against any model.  I also save the controller
since I may be searching the same model from different controllers and
want to keep separate filters.
Search field contains the search term if it is a Sphinx search, and
search_type defines if the search is normal or sphinx
I have a name field which I have not yet implemented but which is
intended eventually to allow users to store pre defined named
searches.
The user is also allowed to change the per_page setting so I save that
too.

To use the search in the controller requires three standard method
calls as below:
 @search=Search.set_search(@user,Product,params)
@filt...@search.filter
@produc...@search.do_search

set_search does an update or create for this user,model,controller.
It uses the params hash to get the controller and to serialize the
current filter fields.

The do search method in the search model makes a call to a method
which I have called 'filtered' in each model being searched (so the
actual search is local to each model).  I havnt used search_logic, but
I guess with that you wouldnt need to have a specific method in each
model.  In the 'filtered' method in the model being searched, I check
to see if I am doing a normal database search, or if it is  Sphinx
search (my form has a search box as well as filter fields).

For the filter fields, I use an instance of the model being searched
which makes building the search form really easy.

It may not be the best approach, but it works for me and I have done
my best to minimise and standardise the code in the controller.
I hope it may at least give you some ideas or provoke some other
responses.

Tonypm

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



[Rails] Re: rjs replace_html with a partial select box not working

2009-12-16 Thread tonypm
is it that  :prompt needs a string ?

Tonypm

--

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




[Rails] mysql character set = UTF-8 on a cloumn in a migration

2009-12-16 Thread tonypm
Hi,

I want to change a single table field to UTF-8, but cant see a way of
defining this in a migration.  Does anyone know if there is a way, or
if it has to be an sql snippet, how would I add that?

Thanks
Tony

--

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




[Rails] mysql error with named_scope and any?

2009-07-13 Thread tonypm

Hi - need some help to pin this one.

Am upgrading a project to  2.3.2.  Have changed has_finder to
named_scope.  But I am getting an invalid mysql syntax error with a
finder that used to work

I have:

Batch
has_many :orders
has_many :line_items, :through=:orders

Order
has_many :line_items

LineItem
named_scope :unmatched, :conditions = {'product_id'=0}

@batch.line_items.unmatched.any?
gives me:  Mysql::Error: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near '*) AS count_line_items_all FROM `line_items` INNER
JOIN `orders` ON `line_items`' at line 1: SELECT count(`line_items`.*)
AS count_line_items_all FROM `line_items` INNER JOIN `orders` ON
`line_items`.order_id = `orders`.id WHERE (((`line_items`.`product_id`
= 0) AND ((`orders`.batch_id = 1479))) AND ((`orders`.batch_id =
1479)))

If I run the query, I can make it work with count(*) or count
(line_items.id) - is this a mysql problem?
Also note the batch id condition is included twice.

If I do
@batch.line_items.any?
I get a valid query:
SELECT count(*) AS count_all FROM `line_items` INNER JOIN `orders` ON
`line_items`.order_id = `orders`.id WHERE ((`orders`.batch_id = 1479))

So am I doing something bad with my named_scope??

Thanks for any help
Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Line Length limit in posts

2009-06-29 Thread Tonypm

Sorry should have said I access the forum via browser on
groups.google.com

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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] rake test:integration appears to load routes twice

2009-06-28 Thread tonypm

Whilst trying to find out why I was having problems running Webrat, I
put a puts into the routes file to see when it was loaded, and noticed
it gets loaded twice.  Is there any problem with this.

It only happens with rake, not if running the test directly.

for a large routes folder, it would add a bit to test startup time.


--~--~-~--~~~---~--~~
You received 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: will_paginate and remember checkboxes

2009-06-26 Thread Tonypm
model).

If anyone is interested in more detail, then I could put some notes
together.  It is the sort of thing that might make a plugin, but I
don't have experience in that at the moment, and the whole thing still
needs a bit of cleaning up.  If I can get it cleaned up in my apps, I
may try to put some time aside to make it a plugin.


Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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] Line Length limit in posts

2009-06-26 Thread tonypm

It has occurred to me several times lately that there seems to be a
bit of an artificial line length limit on the posts.

I wonder if there is something about the way I enter them, but
randomly pulling up some  posts it seems pretty consistent.

I wondered if it is a google limitation.  So I googled line length and
didnt really come up with any discussions on the subject, but did find
this post

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/e0e73972c4e54f4f?hl=en

Which has some full length lines.  So there must be a way of doing it,
I just wonder how?

Perhaps I should ask Rachel


Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: admin link in application helper

2009-06-25 Thread Tonypm

Here is how I have done it.


In routes:

map.namespace(:admin) do |admin|
admin.resources :users, :member={:edit_password=:get,
   :update_password=:post }
admin.resources :suppliers
admin.resources :categories
end

Now just use admin in the path methods
eg.
= link_to 'Edit', edit_admin_user_path(@user)
= link_to 'Password', edit_password_admin_user_path(@user)
= link_to 'Back', admin_users_path

In the form:
form_for [:admin,@user] do |f|

But have a look at the routing section on the railsguides site.  There
are quite a few options for setting up routes and I still have to play
with some of them myself.

I am actually planning to eliminate the need for admin in my path
methods by using  :name_prefix=nil in the route.  I think I did this
somewhere once when I needed to move a resource into the admin
namespace.  It simplifies the process since the paths don't need to be
edited.  But then admin wont appear or be required in the url.

Tonypm

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: newbie need help

2009-06-23 Thread Tonypm

All you really need to get started is to get your first scaffold
created.

As already mentioned the ruby on rails guides are absolutely
excellent.  Congrats to those who wrote them by the way.

If you follow through the getting started guide

http://guides.rubyonrails.org/getting_started.html

Once you have your first scaffolded resource, you are good to go.
Tweak it and try different things:

You can decide where to start tweaking.  The most visible place to
start is to adjust the views to checkout your ability to create good
html.  Make sure you have a reasonable understanding of html and css
etc.

Then go into applying some changes into the model and controller to
effect some differences.  You might like to set up pagination etc.

Once you have done some tweaking, you can then go on and create your
own scaffolded resource.

One of the things that took a while before the penny dropped, was
using the api.  Initially these look a bit heavy, and not very
appealing.  Initially it seems like you may never find your way
around.  But you will soon get a feel for the key classes that contain
the main stuff you need.

The other things that took a while to twig, were
 - identify the difference between Ruby and Rails.  Ruby is very
object oriented and as such is very extensible.  Rails therefore is
made up of Ruby classes, and you will be using a combination of basic
Ruby methods along with those provided by Rails.  Often I would find
something in an example in a forum or tutorial, but couldn't find it
documented.  This was because I was looking in the rails api when I
should have been looking in the Ruby api and vice versa.
- some of the methods you are using may also be in gems or plugins so
you may need to look at the specific gem or plugin docs too.  All this
seems obvious when stated, but was hard when I started.

You will find lots of discussions about the Right way to to do
things particularly in the area of keeping your business logic in the
model and not polluting the controller with lots of code.  Another
area that gets lots of debate is the Restful routing.

My advice about these things is to be aware of them, but don't get too
hung up on them in the early stages.  Just get on and make things
work.  When I started I put loads of code into the controller because
I hadn't worked out how to build it into the model.   It soon becomes
apparent thought that this is not the best way to do things and when
you start to move that code into the model it is extremely
satisfying.  Later you will find code that you put into the model that
maybe didn't belong there and you can find other places to put it.

The great thing about Ruby and Rails though is that it is a very
forgiving language.  If something works - it works and that is great.
As you get more experienced you will look back and see better ways of
doing things.  For a period, I started to find when I added
functionality to my early code, I actually ended up with less code
than I started with even with the enhancement included.

For me, the this forum itself has been and continues to be an
extremely valuable resource.  There is virtually no question that you
might have that wont have been answered here already.  Since the
search is a google style search in the forum, it is usually easy to
find what you are looking for.  What I do is just type my whole
question such as how do I ... into the search and very often get
the answer I want.

Reading books is great, and I come from a prehistoric era where
computer time was so limited that you took the manuals home and read
them cover to cover, but that day really has passed.  The amount of
information needed means you cannot just read it all.  The way to go
is to do it and then delve into things you need or don't understand.
The web has really changed things.  I have helped two people get
started with rails, and just doing it is the best way, so start with a
book that will help you do that.   Having said that, I do have a
selection of the books mentioned and they are indeed worthwhile.  You
just have to decide which you need to get started.

hth
Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Display Block Conditionally

2009-06-21 Thread Tonypm

steve

that's the first outline of erb I have seen.  Either it doesn't get
discussed a lot, or it is discussed in places I don't visit.  Anyway,
although I had a broad idea of what was going on under the bonnet, I
had never really seen a clear example of an erb template in action.  I
use haml, and I have often wondered how it hooks into erb.  With your
example, I am inspired to delve into that a bit when I get some spare
time.

Thanks
Tony
--~--~-~--~~~---~--~~
You received 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: assert_valid in unit tests after upgrade to rails 2.3 doesn't work

2009-05-29 Thread Tonypm

hi,

just upgrading to 2.3.2 and getting same, did you resolve this at all?

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: assert_valid in unit tests after upgrade to rails 2.3 doesn't work

2009-05-29 Thread Tonypm

Ok, so

Rails Guide http://guides.rubyonrails.org/testing.html
para 3.5 says it exists - I guess the guide needs amending?

It was deprecated at 2.2.2
 - assert_valid is deprecated. Use assert record.valid? instead
see
http://github.com/rails/rails/commit/d4754677a34d34d4a0955a04f2cc6571bdc5e82d
and
https://rails.lighthouseapp.com/projects/8994/tickets/1470-assert_valid-undefined-in-edge-activesupporttestcase

I didnt want to go change all my tests just at the moment, so putting
assert_valid in my test_helper gets me over that for the moment.  Bit
of a time waster, since I was going from 2.0.2 to 2.3 so had not seen
the dep error.

def assert_valid(record)
  assert record.valid?, record.errors.full_messages.join(\n)
end

Tonypm

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Workling not outputting to production.log

2009-04-11 Thread Tonypm

Albert,

thank you so much for this info.  I have posted this quation twice and
not received a response.

Tried it and it is the solution.

It has been irritating me for a while, but I just haven't had time to
investigate it.

Many thanks
Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: What's 'logger', really

2009-04-09 Thread Tonypm

i find I cant send to logger in production mode
if I am running a script/runner on a model method.

Works in development mode, must be a reason for this although I cant
figure it

Output just seems to go nowhere

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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] logger for script/runner or console in production mode

2009-03-30 Thread tonypm

Hi,

When running in development mode, I have some model methods that I
call via cron + script/runner.  These were nicely writing information
to the log file as a record of activity.

However, in production mode, when calling model methods from script/
runner or script/console, nothing is added to the log file.
Regardless of the log level settings.  I have tried many tests of log
level, and even used log.info? etc to prove the log level is set ok.
The same methods do write to the log ok if called from the
controller.

I haven't found any other post on this question so I am thinking I
must be missing some obvious point here.

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Redbox basic implementation question

2009-03-06 Thread Tonypm

Have a look at

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/f08f412c04e20ed1/d9f22348d07245f5?lnk=gstq=++Open+a+(redbox)+modal+popup+from+inside+a+controller%3F++#d9f22348d07245f5

This was a quickfix, I haven't gone to great lengths to investigate
the js code, but the change I made has worked ok for me with firefox
at least (it has to go in the redbox.js in the public folder).

You may want to look into the code in a bit more depth if you may be
supporting other browsers.

Tonypm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Association through 2 intermediate Models

2009-02-27 Thread Tonypm

perhaps the responses could be a bit more helpful here?

sol,

I have done it through 2 level associations using through

eg.

Sites

has_many :feed_entries, :through=:feeds

I have tried with 3 levels, but never got it to work, ie, how do you
chain the throughs.  I have tried to make sure that the through is in
place at each level, but to no avail.

Perhaps someone may be able to enlighten us.

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: How do I access a variable defined in application.rb from within application.rhtml?

2009-02-25 Thread Tonypm

hi,
Ruby pocket reference looks useful, think I'll order a copy.
Regarding the class method, just wondering when/how this method should
get called.

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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] can this be done without using find_by_sql

2009-02-14 Thread tonypm

Hi,

I am increasingly needing to do some more complex finds involving
several table associations.  I can usually find an SQL solution, but
find it hard to think these out using ActiveRecord find techniques.  I
guess I am thinking in SQL terms, when perhaps there is a way of
thinking in ActiveRecord terms.  Here is an example, I am guessing
this can be done without using find_by_sql

Repair has_many :notes

SELECT * FROM repairs
where exists
(select * from notes where repairs.id=notes.repair_id
   and  and notes.flagged)

Thanks
Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Suggestions for a rails webhost...

2009-02-14 Thread tonypm

Peter,

  The dramatic
 improvement in ping time does make quite a difference to be honest,

Confirms what I was what I was wondering about.

Had a look at bytemark, they look worth following up.

Thanks
Tonypm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: can this be done without using find_by_sql

2009-02-14 Thread tonypm

Just to finish the story.

Sorry -  the distinct in the select is needed, I missed it out.

Going a step further, I now have:

named_scope :flagged_repairs, :select = 'distinct repairs.*', :joins
= :repair_notes, :conditions = [notes.flagged = ?, true]

So in my search, where I am building a dynamic scope (thanks to
railscasts)
I can do:

scope.flagged_repairs.paginate(:page=page, :per_page=per_page)

And it all appears to work!!

Incredibly neat

Tonypm


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: can this be done without using find_by_sql

2009-02-14 Thread tonypm

Fred,

Repair.find :all, :select = 'distinct repairs.*', :joins
= :notes, :conditions = [flagged = ?, true]

nice - many thanks.  just needed to fix notes.flagged
--

In reality I have a generic notes model, so my usage is slightly more
complex:

In Repair I have:

has_many :repair_notes, :foreign_key='note_for'
 
has_many :flagged_repair_notes, :class_name=RepairNote, 
:foreign_key='note_for',
   :conditions={:flagged=true}

Then:

Repair.find :all, :select = 'repairs.*', :joins
= :repair_notes, :conditions = [notes.flagged = ?, true]

Creates lovely sql

SELECT repairs.* FROM `repairs` INNER JOIN `notes` ON notes.note_for =
repairs.id AND (`notes`.`type` = 'RepairNote' ) WHERE (notes.flagged =
1)

I wonder if there is a  way to use the flagged_repair_notes in the
find for flagged repairs.

ps.
I have real admiration for the guys who do the ActiveRecord SQL
generation magic.

Thanks to all
Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: Suggestions for a rails webhost...

2009-02-02 Thread tonypm

Some helpful comments here.  Does anyone have any experience using
these from the UK.

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: best way to store this data in the database

2009-01-05 Thread tonypm

I tend these days to always use the full descriptive words - memory
implications are small, but it is easier to directly display the value
than have code to expand it wherever it is used.  It also tends to
make the code logic easier to follow.

tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: What to call Rails + merb

2008-12-27 Thread tonypm

How about RaiMer
--~--~-~--~~~---~--~~
You received 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: What to call Rails + merb

2008-12-27 Thread tonypm

Using Rails relies heavily on googling - so my vote would go for
naming it something pretty unique.  I've done a lot of reading about
railway track engineering over the recent years.

Tonypm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-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: report generation

2008-12-10 Thread tonypm

If you want to deliver a report in file format, you need to use the
send_data method in the controller.  This causes the user to see the
download  dialog delivering a file for the user to view/save.

How to format the report is another issue.  I use pdf-writer plugin
which allows creation of a pdf file format.  It is a bit fiddly to
use, but is not bad, once you have got your head round how to layout
various elements.  The table format can be a bit limited.  (A new pdf
creator called prawn is under development which).

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



[Rails] Re: what's the smallest device to do Rails development on???

2008-12-03 Thread tonypm

I use an eeepc 900 running Fedora, with Netbeans ide.  (Fedora 10 now
includes Netbeans in the package repository, and now supports wireless
out of the box).

Don't try it with windows though, just too slow.  But Fedora actually
running on the external SDHC card works well for me.

Dual screen handling is pretty cool too, providing the OS can
recognize the screen (HP monitors work well).

I have a PAYG 3 Mobile dongle which I take everywhere with me along
with the eeepc using a large camera bag.  With openvpn, I can remote
connect to a client and fix a problem from virtually anywhere at
anytime.

Touch typing on the keyboard is possible and actually require less
finger movement which as you get used to is less RSI risk.  Mostly
though I just plug in a usb kb and mouse.

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



[Rails] Re: Disabling observe_form AJAX request on submit button click?

2008-11-04 Thread tonypm

I had a similar thing with a form whithout a submit button.  I wanted
to use form observer.  The form only had select fields (and an
autocomplete field).

If I hit enter, the form gets submitted, even if the cursor is in the
autocomplete field.  Never did quite figure it  out but got round it
by using field observers instead.  It seemed like the focus
iinternally in the form was in a virtual submit button.  If I add a
normal text field, the problem goes away.

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



[Rails] Re: interacting select_tags using onchange

2008-10-23 Thread tonypm

1.  You don't need the form tag if you are only updating by ajax.
Html purists might argue the point!

2.  You can use any element to update from a partial.  For example,
give the tr an id as in:
tr id='update_me'
then in the controller,
page.replace_html :update_me   etc.

3.  Sometime I find it easier to include the tr tag in the partial
itself, so that the whole row, not just the inner html gets replaced.
In this case use page.replace :update_me in the controller.

4.  You may find if you get rid of the form tags, that updating
individual tds may work, but I would be wary of it.

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



[Rails] Re: Memory Leak

2008-10-12 Thread tonypm

Thanks Fred,

Fedora updated Ruby to:

ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-linux]

problems now all gone away - much relieved!!

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