[Rails] Re: making ActiveRecord::Base sort by id

2015-06-11 Thread javinto
I would not recommend using a default scope on an ActiveRecord model for sorting. Start your Rails console and try Model.find(1). This will result into: SELECT models.* FROM models WHERE models.id=1 ORDER BY id DESC LIMIT 1 This ORDER BY will be included in every unneccessary query. The above q

[Rails] Re: Need help for Resque job.

2014-08-15 Thread javinto
Hi, Resque works with Redis. Why not use Redis to keep track of executed jobs? Jan Op donderdag 14 augustus 2014 12:11:02 UTC+2 schreef bette...@gmail.com: > > Hi Friends, > > I have a scenario where I am calling a resque jobs within the resque job > which is already initiated. > > The below me

[Rails] Re: Can't mass-assign protected attributes: item

2014-08-15 Thread javinto
Hi, In the code you posted there is no "attr_accessible :item" is there? Jan Op donderdag 14 augustus 2014 23:31:12 UTC+2 schreef Fernando Aureliano: > > Hi! > > I'm using the version of that gem > https://github.com/crowdint/acts_as_shopping_cart for rails 3 > > I did evething with ythe convet

[Rails] Re: :disable_with combined with Ajax form: Possible?

2013-08-08 Thread javinto
Rails 3.2 and later One should use it like this: =submit_tag, data: {disable_with: 'busy'} Op vrijdag 30 juli 2010 13:16:39 UTC+2 schreef Ruby-Forum.com User: > > Hi there, > > I'm trying to have an Ajax form with a submit button that has the > :disable_with feature, but the submit button d

[Rails] Re: Nested attributes - not working in forms

2013-07-13 Thread javinto
The fields_for form helper can only loop over association phone numbers that exist. The way to have new phone numbers added is to build them in advance. E.g. @person.phones.build Or if you want to supply 4 phone number fields: 4.times {@person.phone.build} In that case you should add a rejec

[Rails] Re: Fetch record based on many to many association

2013-02-21 Thread javinto
Why bother and not doing: (user.entries + user.participated_entries).uniq I wonder if a complicated single query is must faster Op woensdag 20 februari 2013 20:20:46 UTC+1 schreef Linus Pettersson het volgende: > > Hi > > Let's say I have three models, Company, User and Entry (and a join mo

[Rails] Re: Complex abilities and scoping of records

2013-02-21 Thread javinto
Have you been looking at CanCan? I've implemented a similar situation with CanCan. It will not cover your needs for 100% but it will do a lot. Op donderdag 21 februari 2013 00:56:53 UTC+1 schreef Tim Uckun het volgende: > > I have the following scenario. > > Users have various levels of abi

[Rails] New route method on every controller

2013-02-21 Thread javinto
Hi In my routes I have a match ":controller/help", :action=>'help' (Rake routes shows: /:controller/help(.:format):controller#help) This will add a help action on every controller, including namespaced controllers. As Rails 4 will not be supporting 'match' anymore I'm conver

[Rails] Re: How to clear ActiveRecord query cache on associations with dynamic table

2013-02-18 Thread javinto
ag 18 februari 2013 22:27:24 UTC+1 schreef javinto het volgende: > > In part of my application I'm using dynamic tables. I'm aware of the > single thread conditions. I've tackled some caveats yet - will post a blog > about it soon - but there's one I need help

[Rails] Re: Login with Ajax

2013-02-18 Thread javinto
The default method for a form_tag is a POST. But in your controller you are only showing a the #new method (GET). Should it not be #create? Op maandag 18 februari 2013 22:15:28 UTC+1 schreef Ruby-Forum.com User het volgende: > > I'm trying to create an Login Form, that is retrieved via Ajax a

[Rails] How to clear ActiveRecord query cache on associations with dynamic table

2013-02-18 Thread javinto
In part of my application I'm using dynamic tables. I'm aware of the single thread conditions. I've tackled some caveats yet - will post a blog about it soon - but there's one I need help with. Consider 2 models that are associated: Order and OrderLine where Order has many order_lines. Now we

[Rails] Re: how to prevent the user from accessing the app.after logout with back button(rails only)

2012-05-10 Thread javinto
Several solutions in the before mentioned post were suggested. I used: before_filter :set_cache_buster def set_cache_buster response.headers["Cache-Control"] = "no-cache, no-store, max- age=0, must-revalidate" response.headers["Pragma"] = "no-cache" response.headers["Expires"] = "

[Rails] Re: Deployment problem after update to rails 3.2.1

2012-02-02 Thread javinto
Ha ha, yeah it is. Just checked with another project and it should run the after_update_code callbacks first! But it isn't. Same Capistrano version I will seek some Capistrano help. Thanks so far! On 2 feb, 19:47, Greg Akins wrote: > On Thu, Feb 2, 2012 at 1:45 PM, javint

[Rails] Re: Deployment problem after update to rails 3.2.1

2012-02-02 Thread javinto
the Bundle command. I cannot remember it normally does. On 2 feb, 19:24, Greg Akins wrote: > On Thu, Feb 2, 2012 at 1:20 PM, javinto wrote: > > *** [err :: ] rake aborted! > > *** [err ::  No such file or directory - /var/www/vhosts/server/rails/ > > releases/201202021

[Rails] Re: Deployment problem after update to rails 3.2.1

2012-02-02 Thread javinto
ks like the symlink which is automatically applied by Capistrano does not get fired. I'm out of ideas. On 2 feb, 18:20, Greg Akins wrote: > On Thu, Feb 2, 2012 at 11:58 AM, javinto wrote: > >    [server] executing command > > *** [err :: server] rake aborted! > >

[Rails] Deployment problem after update to rails 3.2.1

2012-02-02 Thread javinto
Hi! I updated my application from Rails 3.1.x to 3.2.1. I followed the update instructions in the Rails Guide which hardly requires any modifications apart from development mode. On my local machine - running development mode - the application is running fine using Ruby 1.9.3 with the mysql2 gem.

[Rails] Re: Rails 2.3.8 - InvalidAuthenticityToken problem. URGENT!

2010-09-21 Thread javinto
I get this error regularly after having updated my app to Rails 2.3.9! Especially after not having logged out properly but having shut down my server instance. On Sep 20, 10:41 pm, wb5aty wrote: > Same thing to me.These dam computer suck dont they. > > On Sep 20, 12:55 pm, chris wrote: > > >

[Rails] Re: Rails 2.3.x documentation archive?

2010-09-13 Thread javinto
It was definitely unclear as where to find the archived documentation. Even Google gave me trouble finding it Finally I came across: http://rdoc.info/docs/rails/2.3.8/frames On Sep 13, 5:48 am, gamov wrote: > api.rubyonrails.org/v2.3.8/index.html > guides.rubyonrails.org/v2.3.8 > > On Sep 11, 3

[Rails] Re: Ruby PRAWN PDF generatiog values from controller

2010-08-13 Thread javinto
Hi, Use the :column_widths=>{0=>100,1=>100, 2=>100, etc..} property. Jan On Aug 13, 9:27 am, Jeffrey Bonson wrote: > I have a file named report.pdf.prawn, > which is the view part of my PDF file where we can edit the contents of > the PDF file like >>> > pdf=Prawn::Document.new(:page_layout =>

[Rails] Re: ajax and redirect

2010-06-06 Thread javinto
Hi, What you cannot do is mixing Ajax requests with full URL page requests But what you can do is something like: format.js { render :action=> search_show, :layout=>false } Your search_show view will be rendered without any application layout provided you're using the same co

[Rails] Re: Ajax fails in IE8

2010-06-05 Thread javinto
Hi, As I have to guess your code, I can just share my experience with Ajax and IE. I recently had a similar problem with the Ajax :update=>'<#id>' call. I updated a element which went perfect in Firefox, but not in IE. After changing the element into a my code fired in IE as well. So, you migh

[Rails] Re: Printed/PDF Reports (Text/Tabular/Summary) in Rails

2010-05-21 Thread javinto
I just started using Prawn. It's in alpha but it's already pretty usefull. Table lay-outs neatly reproduce themselves over multiple pages with repeating headers. And that just in 1 line of code!!! Jan On May 21, 12:54 am, Marnen Laibow-Koser wrote: > Jeremy Cowgar wrote: > > [...] > > > Any sugge

[Rails] Re: uninitialized constant ActiveSupport::Cache (NameError)

2009-06-10 Thread jan . javinto
> > > rubygems-update (1.3.4) > > > rubyist-aasm (2.0.5) > > > sources (0.0.1) > > > sqlite3-ruby (1.2.1) > > > syntax (1.0.0) > > > test-unit (2.0.2) > > > win32-api (1.4.2) > > > win32-clipboard (0.5.1) > > > win

[Rails] Re: uninitialized constant ActiveSupport::Cache (NameError)

2009-06-10 Thread jan . javinto
gt; > win32-sapi (0.1.4) > > win32-service (0.6.1) > > win32-sound (0.4.1) > > windows-api (0.3.0) > > windows-pr (1.0.5) > > > But the error still remains. > > > Jan > > > On 10 jun, 17:24, Maurício Linhares > > wrote: > >> Wow, you

[Rails] Re: uninitialized constant ActiveSupport::Cache (NameError)

2009-06-10 Thread jan . javinto
t; > gem clean > > Should do it. Maybe you're getting a conflict of old gems trying to > access new rails code. > > - > Maurício > Linhareshttp://codeshooter.wordpress.com/|http://twitter.com/mauriciojr > >

[Rails] uninitialized constant ActiveSupport::Cache (NameError)

2009-06-10 Thread javinto
Hi After having updated some GEMS I get `load_missing_constant': uninitialized constant ActiveSupport::Cache (NameError) on starting the server of a freshly generated rails project. Before, I already had Rails 2.3.2 projects succesfully running, now all of them generate this error. These are my

[Rails] HTTP Digest Authentication not working

2009-04-09 Thread javinto
Hi to all, I've created a new project with Rails 2.3.2 and literally copied the HTTP Digest Authententication example from the documentation into a SecretsController: class SecretsController < ApplicationController Users = {"dhh" => "secret"} before_filter :authenticate def secret re

[Rails] Re: SQL OR in Rails

2008-10-21 Thread javinto
not always trust the IDE I guess, or does it have something > to do with the fact that you moved the constant to the end? > > Kind Regards, > Schalk > > javinto wrote: > > Hi Schalk > > > Just use: > > > @states = States.find(:all, :conditions => ["co

[Rails] How to force a lock_version increment

2008-10-21 Thread javinto
Hi everyone, I have a order with order_lines use case. On changing the lines, I want to be sure no one else changed the order. So I use lock_version on the order. This works fine if something is changed on the order record. But now i have the situation that I delete, alter and add order lines wi

[Rails] Re: SQL OR in Rails

2008-10-21 Thread javinto
Hi Schalk Just use: @states = States.find(:all, :conditions => ["country=? OR country='International'", LOCALE]) Jan On 21 okt, 12:50, Schalk Neethling <[EMAIL PROTECTED]> wrote: > Hi there everyone, > > How does one set-up a SQL OR query in Rails. > > I have the following SQL query: > > sele

[Rails] Re: Configuring custom library

2008-09-08 Thread javinto
]> wrote: > Most of the Rails libraries use the following pattern: > > class Something >   @@config1 = "change_me" >   cattr_accessor :config1 > end > > Something.config1 = "secret code" > > On Sep 7, 10:38 am, javinto <[EMAIL PROTECTED]> wrote:

[Rails] Re: Configuring custom library

2008-09-07 Thread javinto
  end > > >   ... > > end > > > class ApplicationController < ActionController::Base > >   include AccountSystem > > >   # this is how you would use it > >   def random_method > >     if single? > >       puts "single" > >     e

[Rails] Configuring custom library

2008-09-06 Thread javinto
Hi, I've added a custom library called lib\AccountSystem like so: "module AccountSystem SINGLE = 1 MULTIPLE = 2 class << self attr_accessor :account_system_type end end" Now I wanna configure AccountSystem.account_system_type=AccountSystem::SINGLE in one app. I used an initialize