[Rails] Re: rake db:test:prepare

2012-04-03 Thread Dheeraj Kumar
I do this in my bashrc: alias migrate='bundle exec rake db:migrate; RAILS_ENV=test bundle exec rake db:migrate;' Not sure of the syntax but you get the idea. I don't use rake or rake spec, and prefer running a guard/spork combo. Hence whenever I want to run a migration, I just run 'migrate' an

[Rails] Re: Pessimistic locking locks the entire table?

2012-04-03 Thread PierreW
I don't know if using pessimistic locking is the best way to do it, but here is why I used this: - every X hours a demon runs and updates records - thing is, this demon "action" can last Y with Y > X So there is a risk that two instances of the demon try to update the same record. So each demon n

[Rails] Re: Pessimistic locking locks the entire table?

2012-04-03 Thread Robert Walker
wam r. wrote in post #1054714: > Hi guys, > > I must be missing something obvious with pessimistic locking. Here is > what I do (Rails 2.3, mySQL): So is there a reasonable use case for pessimistic locking on a web application? That seems insane to me. -- Posted via http://www.ruby-forum.com/.

[Rails] Re: one master table to hold symbols: good or bad idea?

2012-04-03 Thread Fearless Fool
Tim Shaffer wrote in post #1054854: > What problem are you trying to solve by doing this? > > Just seems like it would make your code more complicated with no real > benefit. DRYer code: this approach has fewer distinct tables, fewer distinct classes, fewer things to test and maintain. But I may

[Rails] Re: RoR and SQL issu

2012-04-03 Thread Miguel A.
> Your rails app will only use the gems specified in your Gemfile (and > their dependencies). If it's not in your Gemfile, it's not loaded, > even if it is already installed > > Fred Thank you for the explanation and time dedicated Fred Best regards -- Posted via http://www.ruby-forum.com/. -

[Rails] Re: RoR and SQL issu

2012-04-03 Thread Frederick Cheung
On Apr 3, 11:06 pm, "Miguel A." wrote: > Im using rails 3.2.2 na in my: > C:\Ruby187\lib\ruby\gems\1.8\gems > > folder I can see the: > mysql-2.8.1-x86-mingw32, mysql2-0.3.11-x86-mingw32 and > mysql2-0.3.11-x86-mswin32-60 > > folders. > > Doesn't this mean its installed already? :/ Your rails

[Rails] Re: RoR and SQL issu

2012-04-03 Thread Miguel A.
> Your Gemfile lists all the gems your app uses, if you're using the > mysql2 gem you'd need > > gem 'mysql2' > > (If you're using an older rails version you may need to specify a > version of mysql2 that is compatible with your rails version. Im using rails 3.2.2 na in my: C:\Ruby187\lib\ruby\ge

[Rails] Re: RoR and SQL issu

2012-04-03 Thread Frederick Cheung
On Apr 3, 10:48 pm, "Miguel A." wrote: > I've set up on Windows 7 Eclipse with ruby and radrails and want to use > MySQL as a database. > I've executed: gem install mysql2 > And changed the database.yml what did you change it to? I'd wager you've got adapter: mysql, whereas it should be adapter

[Rails] RoR and SQL issu

2012-04-03 Thread Miguel A.
I've set up on Windows 7 Eclipse with ruby and radrails and want to use MySQL as a database. I've executed: gem install mysql2 And changed the database.yml I have tried to use MySQL 5.5 and 5.1 and the error still exists. rake aborted! Please install the mysql adapter: `gem install activerecord-m

[Rails] Re: rake db:test:prepare

2012-04-03 Thread Frederick Cheung
On Apr 3, 9:43 pm, "@1337807" wrote: > Why is it necessary for me to run 'rake db:test:prepare' when I generate a > new model? > it shouldn't be - if you run rake (which defaults to running rake test or rake spec depending in your setup) it runs rake db:test:prepare for you > Shouldn't the 'rak

[Rails] Re: Pessimistic locking locks the entire table?

2012-04-03 Thread Frederick Cheung
On Apr 3, 7:52 pm, PierreW wrote: > Hi Scott, > > Thanks. In case it helps others, it is explained here: > > http://stackoverflow.com/questions/6690458/innodb-select-for-update-s... > > Setting transaction to Read Committed did not work for me though, but > creating an index on UpdateLockForFoo

[Rails] Re: rescuing ActiveRecord::RecordNotUnique: clever or ugly?

2012-04-03 Thread Fearless Fool
Let me redact that previous post...my only excuse is that I hadn't had my coffee yet! If the time to make a DB query (let's call it 1 Unit of time) swamps out any amount of processing in Ruby, then: Approach A (do a SELECT to check for existence of the record before attempting an insert) will tak

[Rails] tinymce-rails-imageupload

2012-04-03 Thread Begler Emirhanov
Hi. I have a beginner level. And I can not get the image url (i do not know how). https://github.com/Atlantia/tinymce-rails-imageupload Create name = params[:file].original_filename directory = "public/data" #create the file path path = File.join(directory, name) #write the fi

[Rails] Upload files in directory

2012-04-03 Thread Sayed G. Farag
I use Rails 3.2.2 and i created a web application. I want to upload files and save them in assets directory and save its locations in DB. how can i do that? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email

[Rails] Re: pass iframe through sanitize

2012-04-03 Thread Shlomi Zadok
In config/initializers/sanitizer.rb add: HTML::WhiteListSanitizer.allowed_tags << 'iframe' On Mar 24, 9:56 am, Grigory Antonov wrote: > Hello, > I want to let users place in textfield an iframe tag from google maps. > Sanitize cuts everything. I want to  add some kind of rule to sanitize, so >

[Rails] rake db:test:prepare

2012-04-03 Thread @1337807
Why is it necessary for me to run 'rake db:test:prepare' when I generate a new model? Shouldn't the 'rake db:migrate' also affect the test database? Why would anyone want to preserve the (broken) state of their test database? Am I missing something? -- You received this message because you ar

[Rails] streaming partials

2012-04-03 Thread Anton Baronov
Hi everyone! I'm looking for a railsy way to stream partial views in Rails 3.2+. Right now streaming is supported only for yielding via provide. But say I have 10 posts in a blog page, and each post is generated in partial in about 300ms and I want user to start reading the first post immediately a

[Rails] Rack-Cache and Streaming... incompatible?

2012-04-03 Thread Matthew Fordham
Hi all, I am attempting to stream a CSV file from a Rails 3.2 application. All works as expected IF I disable Rack-Cache... but I really want to keep the caching if possible. Setting 'Cache-Control: no-cache' for the response didn't help. Here is my SO post on the topic: http://stackoverflow.

[Rails] grouped_collection_select

2012-04-03 Thread Abram
Ok, so I have table called 'products' which has 'brand' and 'model' columns... I would like to pull all models and categorize them by brand in the pull down menu by means of grouped_collection_select. Is this possible or do I need to reorganize my entire db to have brand model and submodel tables?

[Rails] rspec-expectations-2.9.1 is released!

2012-04-03 Thread David Chelimsky
rspec-expectations-2.9.1 is released! This is a bug-fix only release, and is recommended for everybody using rspec-2.9. ### rspec-expectations-2.9.1 / 2012-04-03 [full changelog](http://github.com/rspec/rspec-expectations/compare/v2.9.0...2.9.1) Bug fixes * Provide a helpful message if the di

Re: [Rails] Pessimistic locking locks the entire table?

2012-04-03 Thread PierreW
Hi Scott, Thanks. In case it helps others, it is explained here: http://stackoverflow.com/questions/6690458/innodb-select-for-update-statement-locking-all-rows-in-a-table Setting transaction to Read Committed did not work for me though, but creating an index on UpdateLockForFoo did the trick.

[Rails] Re: How to disable has_secure_password validation when a condition is true?

2012-04-03 Thread IAmNan
Did you ever get a solution to this? My app also allows authentication outside without the password. On Feb 15, 9:23 pm, David M wrote: > Yes, I already watched those screencasts, but I still don't know how to do > it. -- You received this message because you are subscribed to the Google Groups

[Rails] Re: one master table to hold symbols: good or bad idea?

2012-04-03 Thread Tim Shaffer
What problem are you trying to solve by doing this? Just seems like it would make your code more complicated with no real benefit. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.

[Rails] one master table to hold symbols: good or bad idea?

2012-04-03 Thread Fearless Fool
(This is may be more of a db design question than a rails question.) Summary: I'm thinking of creating a single AR class to hold constant symbol values and use it for :has_many_through relations whenever I need a constant symbol. Is this a good idea or a bad idea? Details: I notice that I have

Re: [Rails] Custome render xml

2012-04-03 Thread محمد شحاته
Thank u very much , that is what i need :) On Tue, Apr 3, 2012 at 5:51 PM, Peter Vandenabeele wrote: > On Tue, Apr 3, 2012 at 4:18 PM, M.SH wrote: > > i want to make render xml for an complex object > > ex > > make render :xml => posters > > poster = [name, post_id,created_at, ] > > po

[Rails] Re: rescuing ActiveRecord::RecordNotUnique: clever or ugly?

2012-04-03 Thread Fearless Fool
Joe V. wrote in post #1053641: > A SQL query takes around 1 ms, possibly more if the db server is on a > different machine. That is way more expensive than rescuing an > exception. Joe: Thanks for the useful data point. Just to make sure my understanding is complete, since any db transaction is

[Rails] Re: Problem: jruby -S bundle install - tries to build native extension of yajl-ruby

2012-04-03 Thread YogiZoli
On win you may wanna use Pik as an alternative of RVM, or you can use RVM with cgywin, or alternatively using Virtual Machine. I highly recommend using RVM somehow because you're gonna have Gem version problems all the time which is really annoying. This article makes things clear: http://yehudaka

[Rails] Re: New Rails User stuck on tutorial => Updating Posts/Mass Assignment

2012-04-03 Thread YogiZoli
Hi, yes, I had the same problem yesterday, and I'm also going through a tutorial - maybe the same one? Solved with 2 steps: added attr_accessible as mentioned earlier message. Also I had to change the RSpec tests from before @user = User.new(name:"Example", email:"exam...@gmail.com").tap d

[Rails] Re: devise authenticate_user! causing test fail

2012-04-03 Thread Aashish Kiran
Aashish Kiran wrote in post #1054821: > Dheeraj Kumar wrote in post #1054781: >> login_user should be inside a before_each block. >> >> >> Dheeraj Kumar > > The updated code is at. > > http://pastie.org/3719793 > > The module is not loaded properly. In http://pastie.org/3719793 If I remove before_

Re: [Rails] Custome render xml

2012-04-03 Thread Peter Vandenabeele
On Tue, Apr 3, 2012 at 4:18 PM, M.SH wrote: > i want to make render xml for an complex object > ex >   make render :xml => posters > poster = [name, post_id,created_at, ] > post = [title, body,created_at, ] > > and i want the render output to be > > >     >         >             nam

Re: [Rails] Pessimistic locking locks the entire table?

2012-04-03 Thread Scott Ribe
On Apr 2, 2012, at 4:33 PM, PierreW wrote: > My > understanding was that :lock => true only locks a specific record, but > it seems it is not the case and it locks the entire table. That depends on what kind of locking the underlying database offers. Which with MySQL depends on the storage manag

[Rails] Custome render xml

2012-04-03 Thread M.SH
i want to make render xml for an complex object ex make render :xml => posters poster = [name, post_id,created_at, ] post = [title, body,created_at, ] and i want the render *output* to be name title

[Rails] Re: devise authenticate_user! causing test fail

2012-04-03 Thread Aashish Kiran
Dheeraj Kumar wrote in post #1054781: > login_user should be inside a before_each block. > > > Dheeraj Kumar The updated code is at. http://pastie.org/3719793 The module is not loaded properly. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed

Re: [Rails] passing json parameter in ruby on rails

2012-04-03 Thread murali dhararao
Hi, Get the data of branch=params[:branch] [:branch_id] unless params[:branch].nil? send this branch to the method. On Tue, Apr 3, 2012 at 5:48 PM, amvis wrote: > > i need to get the values from the :branch. so when i call the function * > authenticate_for_branch*, how to pass that branch

Re: [Rails] passing json parameter in ruby on rails

2012-04-03 Thread amvis
i need to get the values from the :branch. so when i call the function * authenticate_for_branch*, how to pass that branch and accept that...? Thank you vishnu On Tuesday, 3 April 2012 08:09:14 UTC-4, Colin Law wrote: > > On 3 April 2012 12:55, amvis wrote: > > Just i called one function in

Re: [Rails] passing json parameter in ruby on rails

2012-04-03 Thread Colin Law
On 3 April 2012 12:55, amvis wrote: > Just i called one function in my program, but i need to pass one > json parameter...But getting the error like > ArgumentError (Unknown key: branch_id): > > CODE > > branch1(params[:branch]) > > def branch1(branch) >   branch123 = Branch.find(params[:branch])

[Rails] passing json parameter in ruby on rails

2012-04-03 Thread amvis
Just i called one function in my program, but i need to pass one json parameter...But getting the error like *ArgumentError (Unknown key: branch_id):* * * CODE * * *branch1(params[:branch]) * * * *def **branch1**(branch) * * branch123 = Branch.find(params[:branch]) * *end* * * And my rest-client

[Rails] Re: How to extract an image and its info from MP3 file.

2012-04-03 Thread Dheeraj Kumar
taglib-ruby. Next time, please google before posting. Dheeraj Kumar On Tuesday 3 April 2012 at 3:44 PM, Rajesh B. wrote: > Hi > > > I am developing a music related project. in ruby on rails > > in that when a user uploads an mp3 file . can i extract its image if > present and other inform

[Rails] How to extract an image and its info from MP3 file.

2012-04-03 Thread Rajesh B.
Hi I am developing a music related project. in ruby on rails in that when a user uploads an mp3 file . can i extract its image if present and other information like artist, album by artist, similar to i tunes player does. So is there any possibility to do that ? Thanks in advance Rajesh Rathod

[Rails] Re: devise authenticate_user! causing test fail

2012-04-03 Thread Dheeraj Kumar
login_user should be inside a before_each block. Dheeraj Kumar On Tuesday 3 April 2012 at 3:34 PM, Aashish Kiran wrote: > Hi all, > I could not run a simple test case. My app uses devise,rspec, etc. The > problem code is at http://pastie.org/3719793 > > can anyone please help > Thank you, > A

[Rails] devise authenticate_user! causing test fail

2012-04-03 Thread Aashish Kiran
Hi all, I could not run a simple test case. My app uses devise,rspec, etc. The problem code is at http://pastie.org/3719793 can anyone please help Thank you, Aashish -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on

Re: [Rails] Re: Strictly related models

2012-04-03 Thread Colin Law
On 2 April 2012 23:10, Serafino Picozzi wrote: > There is no reverse, it's a regular has_one belongs_to association. The reverse relation is then MenuItem has_one Page. That is what you had not told us. Colin -- You received this message because you are subscribed to the Google Groups "Ruby

Re: [Rails] issues with model in ruby on rails

2012-04-03 Thread amvis
Thanks, got the solution... On Tuesday, 3 April 2012 04:20:50 UTC-4, pavling wrote: > > On 3 April 2012 09:12, amvis wrote: > > class User < ActiveRecord::Base > > has_one :system_admin > > end > > > > @user = User.find_by_user_name(user_name) > > if !@user.system_admins.nil? > >

[Rails] Re: distinctively difficult to do what I want

2012-04-03 Thread bingo bob
drat another road block... So now I wish to create Names and I can't fiond the secret sauce. my old create action was simply a variation on the normal..something like this.. def create @name = Name.new(params[:name]) respond_to do |format| if @name.save else end end end How

Re: [Rails] issues with model in ruby on rails

2012-04-03 Thread Michael Pavling
On 3 April 2012 09:12, amvis wrote: > class User < ActiveRecord::Base >   has_one  :system_admin > end > > @user = User.find_by_user_name(user_name) >               if !@user.system_admins.nil? >                  puts 'am a sys_admin' > > The above code gives error Since you've defined the associ

[Rails] issues with model in ruby on rails

2012-04-03 Thread amvis
*class SystemAdmin < ActiveRecord::Base* * belongs_to :user* *end* * * *class User < ActiveRecord::Base* * has_secure_password* * * * has_one :system_admin * *end* * * *@user = User.find_by_user_name(user_name)* * if !@user.system_admins.nil?* * puts 'am a sys_adm