Rails

Rails and PostgreSQL: Role postgres does not exist

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have installed PostgreSQL on my Mac OS Lion, and am working on a rails app. I use RVM to keep everything separate from my other Rails apps. For some reason when I try to migrate the db for the first time rake cannot find the postgres user. I get the error FATAL: role "postgres" does not exist I have pgAdmin so I can clearly see there is a postgres user in the DB - the admin account in fact - so I'm not sure what else to do. I read somewhere about people having issues with PostgreSQL because of which path it was installed in, but then I don

Ruby on Rails Mac OSX Mavericks issues after RVM install

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have been learning Ruby on Rails for a couple of months, and everything was working. Then, for the needs of a tutorial, I tried to install RVM, in order to downgrade my setup to older versions of Ruby and Rails. And since then, I kept running into troubles. For instance, anytime I launch a new Terminal session, here is what I get: You are using '.rvmrc' , it requires trusting , it is slower and it is not compatible with other ruby managers , you can switch to '.ruby-version' using 'rvm rvmrc to [.]ruby-version' or ignore this

Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I am trying to run mysql client on my terminal. I have installed the latest mysql gem. ~ git :( master ) ruby - v ruby 1.8 . 7 ( 2010 - 01 - 10 patchlevel 249 ) [ universal - darwin11 . 0 ] ~ git :( master ) rails - v Rails 2.3 . 14 ~ git :( master ) which mysql mysql : aliased to nocorrect mysql ~ git :( master ) which ruby / usr / bin / ruby ~ git :( master ) which rails / usr / bin / rails ~ git :( master ) gem list *** LOCAL GEMS *** actionmailer ( 2.3 . 14 ) actionpack ( 2.3 . 14 ) activerecord ( 2.3 . 14 ) activeresource ( 2

Ruby on Rails nil can't be coerced into BigDecimal

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Why do I get nil can't be coerced into BigDecimal when I try to perform a calculation: here's the code: model/drink.rb class Drink model/menu.rb class Menu :destroy accepts_nested_attributes_for :drinks, :allow_destroy => true #Validations end * Drink is the (nested)child model and Menu the parent model When I attempt to create a new drink the browser display following error message nil can't be coerced into BigDecimal app/models/drink.rb:7:in 'total-amount' app/controllers/menus_controller.rb:47:in 'create' app/controllers/menus_controller

Rails 3.1 newbie : where should I put javascript code?

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am developing Rails 3.1 application, I get confused about where should I put my own javascript code(e.g. my.js ) and where to put 3rd-party javascript library (e.g. jQuery-UI ). I know in the old version Rails, javascript should all goes into public/javascripts/ directory, when I generate Rails 3.1 app, there is no public/javascripts/ folder, but there is app/assets/ and verndor/assets/ and there is application.js in app/assets , I would like to ask: in Rails 3.1 ,where should I put my.js and jQuery-UI js in Rails 3.1?? what is the app

Ruby on Rails - passing params into 301 redirect in routes.rb

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to change my existing 'game' routing inside routes.rb, but because of SEO I need also to setup 301 redirect for old links. My old routing: match 'games/:permalink/:id/(:page)' => 'games#show' New routing: match 'gierki/:permalink/(:page)' => 'games#show' Here is redirection which I tried to to do: match 'games/:permalink/:id/(:page)' => redirect {|params| "/gierki/#{params[:permalink]}" + params[:page].nil? ? "" : "/#{params[:page]}" } Above redirect is not working, here is an error: wrong number of arguments (1 for 2) 回答1: Try making

Routing Error ― No route matches [POST] “/posts/new”

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm working through the rubyonrails.org 'blog tutorial', and get this error when I try to submit a 'post' : Routing Error --No route matches [POST] "/posts/new" I copied and pasted the code from the tutorial into my code. This should return a hash with the text and title of the post, but instead I get the above error. Here is my view: <%= form_for : post , url : posts_path do | f | %> <p> <%= f . label : title %> <br> <%= f . text_field : title %> </p> <p> <%= f . label : text %> <br> <%= f . text_area : text %> </p> <p> <%= f .

Rails: How to handle “Attribute was supposed to be a Array, but was a String” error?

匿名 (未验证) 提交于 2019-12-03 01:38:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a table with one column that is of text type. There's a small string in it that should be serialized as an array serialize :image_urls, Array There are times when SQL is just faster for inserting data. When this is the case, I do the insert as a string ["image1.jpg", "image2.jpg"] Since I'm inserting a string my Rails app crashes when it tries to read the data, with the following error message: Attribute was supposed to be a Array, but was a String Is there a way to not have this error thrown, or to catch it and convert the data? I

How to use the Rails shopify_app gem with a private API key?

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to use the Rails *shopify_app* gem with a private API key. The documentation for the gem mentions that it's possible to do this but doesn't say how. The instructions are only for a Shopify Partner Account. For a private api key there seems to be no way of specifying the return url . This results in the following response fragment being sent back: {"error":"invalid_request","error_description":"The redirect_uri and application url must have matching hosts"} I've looked around a bit but was not able to find a solution to this. It

Rails Devise PG::SyntaxError: ERROR: zero-length delimited identifier at or near “”“”

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to add a new devise model. When I use the sign_up path I'm able to create a user but throws an error after the new user (doctor) is saved. The error isn't very helpful so I'm hoping someone could point me in the right direction for debugging. The error is ActiveRecord::StatementInvalid in Devise::RegistrationsController#create PG::SyntaxError: ERROR: zero-length delimited identifier at or near """" LINE 1: ...in_ip" = $4, "sign_in_count" = $5 WHERE "doctors"."" IS NULL ^ : UPDATE "doctors" SET "current_sign_in_at" = $1, "current