トップページ⇒php
1001コメント455KB

【RoR】Ruby on Rails Part12

■ このスレッドは過去ログ倉庫に格納されています
0001nobodyさん2011/07/19(火) 13:44:46.30ID:zxrusyvr
■前
【Ruby】Ruby on Rails Part11
http://hibari.2ch.net/test/read.cgi/php/1292032736/

■参考サイト
<英語>
本家:http://rubyonrails.org
API document:http://api.rubyonrails.com/
開発者のblog:http://weblog.rubyonrails.org/
参考wiki:http://wiki.rubyonrails.org/rails
http://ruby-toolbox.com/
http://rubygems.org/
http://agilewebdevelopment.com/plugins/top_rated

<日本語>
Rails' wiki: http://wiki.fdiary.net/rails/

http://twitter.com/dhh
http://www.loudthinking.com/
0630nobodyさん2011/09/24(土) 10:43:39.29ID:???
>>629
できました。有難うございました。マジ感謝です。
なるほど。これはHTML5関係なんですね。
便利ですね。
0631nobodyさん2011/09/24(土) 14:12:09.48ID:???
Railscasts - PayPal Basics
http://railscasts.com/episodes/141-paypal-basics

Railscasts - PayPal Notifications
http://railscasts.com/episodes/142-paypal-notifications

Railscasts - PayPal Security
http://railscasts.com/episodes/143-paypal-security

Railscasts - Active Merchant Basics
http://railscasts.com/episodes/144-active-merchant-basics

Railscasts - Integrating Active Merchant
http://railscasts.com/episodes/145-integrating-active-merchant

Railscasts - PayPal Express Checkout
http://railscasts.com/episodes/146-paypal-express-checkout

0632nobodyさん2011/09/24(土) 18:08:06.72ID:???
model validateが動かなくて今日の午後が潰れた。
原因はvalidateじゃなく、validatesだった。sが抜けてた。泣いた。
0633nobodyさん2011/09/24(土) 18:31:01.78ID:???
と、思ったらまだ動いていなかった・・・
0634nobodyさん2011/09/24(土) 18:37:59.64ID:???
と、思ったら動いてた



少し休もう
0635nobodyさん2011/09/24(土) 21:38:19.99ID:zBp5Lw5x
ARのincludesとjoinsの動作がよくわからず、質問させてください。

rails consoleで
u = User.includes(:authentications).where('id = 1')
のようにしますと、

=> [#<User id: 1, gender: nil, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil,
sign_in_count: 4, current_sign_in_at: "2011-08-28 09:48:13", last_sign_in_at: "2011-06-21 13:53:24", current_sign_in_ip: "192.168.0.3", last_sign_in_ip: "192.168.0.5", created_at: "2011-06-20 10:50:38", updated_at: "2011-08-28 09:48:13">]

06366352011/09/24(土) 21:40:27.99ID:zBp5Lw5x
と返ってきたのですが、この中にはauthenticationsに関するデータは見当たりません。
authenticationsのデータはどこに格納されているのでしょうか?

u.to_jsonのようにしてみても、Userモデルの情報しか表示されません。

教えていただけますと幸いです。
0637nobodyさん2011/09/24(土) 22:18:44.17ID:???
u.authentications
06386352011/09/24(土) 22:42:39.21ID:zBp5Lw5x
レスありがとうございます。
u.authentications を実行すると

NoMethodError: undefined method `authentications' for #<ActiveRecord::Relation:0x0000000262c990>

となってしまいました・・

使用しているARのバーションは3.1.1.rc1です。
最近アップデートしたのですが、する前からこのような感じでした。。
0639nobodyさん2011/09/24(土) 22:45:06.31ID:???
Creating an app and deploying it to Heroku - Shopify Wiki
http://wiki.shopify.com/Creating_an_app_and_deploying_it_to_Heroku
Creating an app and deploying it to Heroku using Rails 3 - Shopify Wiki
http://wiki.shopify.com/Creating_an_app_and_deploying_it_to_Heroku_using_Rails_3
https://www.shopify.com/services/signup

http://addons.heroku.com/chargify
https://devcenter.heroku.com/articles/chargify
https://github.com/npverni/chargify-demo

http://thinkit.co.jp/story/2011/04/01/2067
0640nobodyさん2011/09/24(土) 22:56:24.70ID:???
>>638
ネットで断片的に情報をかいつまんでやってたら、
いつまでたってもできないと思うよ。
まずは入門書で少なくともモデルのところを通読するのがお勧め。
0641nobodyさん2011/09/24(土) 22:58:31.54ID:???
>>636
to_json に includes オプションをつける
0642nobodyさん2011/09/24(土) 23:07:50.76ID:???
https://github.com/openhood/paypal

paypal-2.0.0.zip
http://web.archive.org/web/20071016063057/http://dist.leetsoft.com/pkg/paypal-2.0.0.zip
http://web.archive.org/web/20071016063057/http://dist.leetsoft.com/pkg/

Paypal library
http://web.archive.org/web/20090123021721/http://dist.leetsoft.com/api/paypal/
0643nobodyさん2011/09/24(土) 23:10:24.61ID:6AyX50Ec
そのSQLだと、uはid=1のUserのみからなるコレクションだよ。
(返値も [ ... ] で囲まれている)

u[0] とか u.first とかしてみたらどうか。


includes は 1-N 問題を回避するためのeager loadingを行うもの。
SELECT "users".* FROM "users"
で必要なuser idを調べて、それに基づいて authentication をイッキする。
SELECT "authentications".* FROM "authentications"
WHERE "authentications"."user_id" IN (1, 2, 3, 4, 5)

joins は SQL の JOIN句。

SELECT "users".* FROM "users"
JOIN authentications ON authentications.user_id = users.id
0644nobodyさん2011/09/24(土) 23:10:36.73ID:???
SEO業者は容赦なく話をぶった切るな
自動投稿なら当たり前だが
0645nobodyさん2011/09/24(土) 23:37:12.50ID:???
https://github.com/Shopify/active_merchant
http://rubygems.org/gems/activemerchant
http://activemerchant.org/

Ruby 開発備忘録: railsでpaypalを使う方法
http://face-do.blogspot.com/2011/09/railspaypal.html

Rails3 ActiveMerchantでPayPalの設定 | 超ド素人のRuby on Rails挑戦日記
http://hajimete-ruby.jugem.jp/?eid=73

0646nobodyさん2011/09/25(日) 00:21:10.55ID:???
RubyでPayPal - Develop with pleasure!
http://d.hatena.ne.jp/techmedia-think/20090825/1251195366

0647nobodyさん2011/09/25(日) 00:28:30.48ID:???
/var/www/html/ の下にアプリを作って稼働させていく場合って
htmlディレクトリ以下(htmlディレクトリ含む)の権限設定は775でok?

ちなみにrootじゃないユーザーでSSHで入って
アプリを作っていきます。
0648nobodyさん2011/09/25(日) 00:36:44.25ID:???
webからみられる場所からtest/publicに向けてシンボリックリンクを
張ります。
~/wwwの直下に「test」という名前でシンボリックリンクを作ります。
% ln -s $HOME/Rails/test/public $HOME/www/test

http://nyon2.net/archives/2009/01/ruby-on-railsruby-on-rails.html
0649nobodyさん2011/09/25(日) 00:42:00.72ID:???
>>647で追記です。

rootとは別途に作った
sshuserというユーザーでは
rails new test_app を実行したときに
パーミッションエラーが出てしまうので毎回rootで操作しています。

sshuserでsshログインしてアプリを作るときだけsudoするしかないのでしょうか?

またrootでrailsアプリを作ると
別ユーザーのftpuserでftpアクセスしたときに
ファイルの削除が行えません。

皆さんは各種ユーザーはどのように設定していますか?
0650nobodyさん2011/09/25(日) 01:03:37.05ID:???
/var/www の下で共同で開発なんかする訳ない。
ftpなんて使わない。
rails以前にlinuxの勉強しなよ。
0651nobodyさん2011/09/25(日) 03:35:28.07ID:???
>>631
http://www.google.co.jp/search?num=100&q=paypal+rails+site%3Agithub.com
PayPal sandboxでの日本語アカウントの設定について
http://www.nwlab.com/?p=4641
第3回 定期支払いを実現するリカーリングペイメントの実装
http://gihyo.jp/dev/serial/01/paypal_api/0003
https://github.com/openhood/paypal
https://github.com/nov/paypal-express
http://www.slideshare.net/matake/paypalexpress-ruby-gem
https://paypal-express-sample.heroku.com/
https://github.com/Shopify/active_merchant
http://activemerchant.org/
https://developer.paypal.com/devscr?cmd=_signup-run
0652nobodyさん2011/09/25(日) 03:36:04.01ID:???

http://railscasts.com/episodes/141-paypal-basics
http://d.hatena.ne.jp/hrendoh/20110516/1305548398
http://miya.sblo.jp/article/43672066.html
http://face-do.blogspot.com/2011/09/railspaypal.html
http://hajimete-ruby.jugem.jp/?eid=73
http://d.hatena.ne.jp/techmedia-think/20090825/1251195366
http://d.hatena.ne.jp/ikad/20110616/1308220854
http://blog.twiwt.org/e/624776

https://github.com/recurly/recurly-client-ruby
https://github.com/npverni/chargify-demo
http://wiki.shopify.com/Creating_an_app_and_deploying_it_to_Heroku
0653nobodyさん2011/09/25(日) 03:58:39.67ID:???
https://github.com/nov/paypal-express
https://github.com/nov/paypal-express-sample
https://paypal-express-sample.heroku.com/

Setup Sample App
git clone https://github.com/nov/paypal-express-sample
Get PayPal Sandbox Account
Signup at developer.paypal.com
Create sandbox merchant account
Get API username, password and signature
Edit con?g/paypal.yml
bundle & rails
http://www.slideshare.net/matake/paypalexpress-ruby-gem

0654nobodyさん2011/09/25(日) 07:15:15.64ID:???
https://github.com/railsdog/spree-paypal-express
https://github.com/spree/spree_paypal_express
https://github.com/pkordel/spree-paypal-express-demo
http://spreecommerce.com/extensions/143-spree_paypal_express
http://spreecommerce.com/extensions/14-spree-paypal-express
http://spreecommerce.com/blog/tag/paypal
https://github.com/spree
http://spreecommerce.com/

https://github.com/nov/paypal-express



0655nobodyさん2011/09/25(日) 10:39:31.44ID:???
https://github.com/mobalean/subscription_fu
https://github.com/wiseleyb/subscription_fu
https://github.com/wiseleyb/subscription_fu_sample_app

Ninjava/PayPal Express Checkout, Subscriptions - Tokyo PayPal Develope... - mochiz blog
http://mochizblog.heroku.com/10
0656nobodyさん2011/09/25(日) 10:46:54.18ID:???
subscription_fu
https://github.com/mobalean/subscription_fu

ホーム - モバリーン - ソフトウェア開発・コンサルタント
http://www.mobalean.com/ja

請求書.jp
https://www.seikyusho.jp/

https://github.com/nov/paypal-express

iKnow! - 覚えやすく、忘れにくい、確実に身につく英語学習サービス
http://iknow.jp/
0657nobodyさん2011/09/25(日) 11:01:29.30ID:???
https://github.com/agentrock/paypal-express-engine

https://github.com/tc/paypal_adaptive
0658nobodyさん2011/09/25(日) 11:40:35.32ID:???
Rails3 ActiveMerchantでPayPalの設定 | 超ド素人のRuby on Rails挑戦日記
http://hajimete-ruby.jugem.jp/?eid=73

Cody Fauser - PayPal Express Payments with ActiveMerchant
http://www.codyfauser.com/2008/1/17/paypal-express-payments-with-activemerchant

Active Merchant + Paypal Recurring Payment | Naive Hack
http://www.naivehack.com/2010/11/24/active-merchant-paypal-recurring-payment/

Requesting PayPal API Signature - Online documentation - WildApricot help
http://help.wildapricot.com/display/DOC/Requesting+PayPal+API+Signature
06596352011/09/25(日) 15:04:21.72ID:vRBCORhD
お礼が遅れましてすみません。

>>640
ですよね。rails3本買ってみることにします。

>>641
ありがとうございます!これが知りたかったのでした。

>>643
詳しいご説明ありがとうございます。
eager loadingについても調べてみてincludesとjoinsの違いがなんとなく分かって来ました。
0660nobodyさん2011/09/25(日) 23:11:29.94ID:???
Ruby 開発備忘録: railsでpaypalを使う方法
http://face-do.blogspot.com/2011/09/railspaypal.html

signup
https://developer.paypal.com/devscr?cmd=_signup-run
Create a preconfigured account
https://developer.paypal.com/cgi-bin/devscr?cmd=_create-account-session
API Username API Password Signature
https://developer.paypal.com/cgi-bin/devscr?cmd=_certs-session
https://developer.paypal.com/cgi-bin/devscr?cmd=home/main
https://www.sandbox.paypal.com/

http://www.codyfauser.com/2008/1/17/paypal-express-payments-with-activemerchant
http://www.naivehack.com/2010/11/24/active-merchant-paypal-recurring-payment/
0661nobodyさん2011/09/25(日) 23:13:42.48ID:???
http://localhost:3000/payments
0662nobodyさん2011/09/26(月) 01:56:11.13ID:???
nerbie69 off rails: Recurring Payments using PayPal Express and Active Merchant
http://nerbie69.blogspot.com/2008/11/recurring-payments-using-paypal-express.html

paypal_express_recurring_nv.rb
http://www.gotripod.com/2008/09/08/ruby-on-rails-paypal-express-recurring-payments-using-active-merchant/

http://rayvinly.com/articles/2009/02/20/paypal-recurring-billing-with-activemerchant-in-ruby-on-rails/
http://intridea.com/2009/2/23/paypal-recurring-billing-with-activemerchant-in-ruby-on-rails?blog=company

https://github.com/rayvinly/active_merchant/
0663nobodyさん2011/09/26(月) 10:19:53.93ID:???
https://github.com/Shopify/active_merchant
https://github.com/vantran/active_merchant
http://www.naivehack.com/2010/11/24/active-merchant-paypal-recurring-payment/
http://nerbie69.blogspot.com/2008/11/recurring-payments-using-paypal-express.html
http://www.gotripod.com/2008/09/08/ruby-on-rails-paypal-express-recurring-payments-using-active-merchant/

https://github.com/railsdog/spree-paypal-express
https://github.com/spree/spree_paypal_express

https://github.com/nov/paypal-express

https://github.com/fnando/paypal-recurring
0664nobodyさん2011/09/26(月) 20:08:08.60ID:???
入力項目にエラーがあった場合、入力画面に戻り各項目の再表示をさせたいと思っていますが、
password_fieldに入力した文字だけ再表示されません。(●●●●も表示されない。)

■ソース
<%= form_for @user,:url => { :action => 'hogehoge'} do |f| %>

 <%= f.password_field :password, {:size => 20, :maxlength => 20, :required => true} %>

#@user[:password]には、文字列として'hogehoge'が登録されている。

何か別途指定する必要ありますか?
0665nobodyさん2011/09/26(月) 20:10:51.40ID:???
password_fileldはそういうものです。
もう一度入力させます。
0666nobodyさん2011/09/26(月) 20:33:43.12ID:???
有難う。納得しました。
0667nobodyさん2011/09/27(火) 20:02:10.26ID:???
しっかし、このスレ人気ねぇなw
railsがいかに人気が無いか表してる
0668nobodyさん2011/09/27(火) 21:28:06.81ID:???
ここに書く事、特に無いからな。
質問してるのは、ネットだけで何とか習得しようという初心者だし。
質問もはてなとかTwitterで聞いた方が早いし。
あとリンク貼り付けるだけの人力botの存在とか。
0669nobodyさん2011/09/27(火) 22:03:51.28ID:???
ググったりソース読めば大抵何とかなる。
0670nobodyさん2011/09/27(火) 22:07:31.37ID:???
要するにスレの価値なし!
0671nobodyさん2011/09/28(水) 00:47:03.04ID:???
Rubyはソースが簡潔だから、ある程度できる人間にとってはソース読めば解決できるんだよな
既存クラスの拡張も容易だから、気に入らない部分はモンキーパッチも簡単にあてられるし
0672nobodyさん2011/09/28(水) 01:01:13.66ID:???
単にスパムがうざいだけなのだが
0673nobodyさん2011/09/28(水) 01:50:19.68ID:W++Lg7ZH
Google Analyticsで参照元の完全なURLを記録する - GRANADA Hatena @ sotarok
http://d.hatena.ne.jp/sotarok/20070627/1182959279

Reuben Yau ? Blog Archive ? Google Analytics Hack - obtaining full referring URL
http://www.reubenyau.com/google-analytics-hack-obtaining-full-referring-url/
0674nobodyさん2011/09/28(水) 02:00:39.65ID:W++Lg7ZH
「特定ドメインのRefferにmatchする場合はimg src画像を差し替える」
http://b.hatena.ne.jp/otsune/20091020#bookmark-16845957
0675nobodyさん2011/09/28(水) 02:06:43.28ID:W++Lg7ZH
レポートにドメインを含んだ完全な URL が表示されるようにするにはどうすればよいですか。
How do I see the full URL of my pages in my reports? - Analytics Help
http://www.google.com/support/googleanalytics/bin/answer.py?answer=55511&topic=11032
0676nobodyさん2011/09/28(水) 04:19:26.67ID:W++Lg7ZH
simple_format(text) シンプルなルールで改行をフォーマットできるメソッド
http://blog.mudaimemo.com/2008/10/ruby-on-rails-view.html

word_wrap('Once upon a time', 8) # => Once upon\na time

truncate("Once upon a time in a world far far away")
# => "Once upon a time in a world..."
http://api.rubyonrails.org/classes/ActionView/Helpers/TextHelper.html#method-i-truncate

auto_link("Go to http://www.rubyonrails.org and say hello to [email protected]")
http://apidock.com/rails/ActionView/Helpers/TextHelper/auto_link
0677nobodyさん2011/09/28(水) 04:39:44.69ID:???
http://mogok.jp/
https://www.fluxflex.com/
http://www.heroku.com/
http://cloudfoundry.com/
http://www.engineyard.com/
http://www.slicehost.com/
http://www.rackspace.com/
http://www.linode.com/

0678nobodyさん2011/09/28(水) 04:41:58.13ID:???
https://www.dotcloud.com/
0679nobodyさん2011/09/28(水) 04:53:56.87ID:???
Amazon Elastic Compute Cloud (Amazon EC2)
http://aws.amazon.com/jp/ec2/

Amazon Relational Database Service (Amazon RDS)
http://aws.amazon.com/jp/rds/

Amazon Simple Storage Service (Amazon S3)
http://aws.amazon.com/jp/s3/
0680nobodyさん2011/09/28(水) 04:56:52.18ID:???
IaaS型クラウド「さくらのクラウド」について | さくらインターネット
http://cloud.sakura.ad.jp/

さくらのVPS|VPS(仮想専用サーバ)はさくらインターネット
http://vps.sakura.ad.jp/
0681nobodyさん2011/09/28(水) 05:00:28.12ID:???

Cloud FoundryにRails/Sinatra/Nodeアプリをデプロイしてみた - 準二級.jp
http://june29.jp/2011/04/24/rails-sinatra-node-on-cloudfoundry/

さくらインターネットで無理矢理Rails動かすくらいならRackspace使えばよいと思う | maeda.log
http://maeda.farend.ne.jp/blog/2010/01/09/rackspace/

さくらのクラウド、Amazon EC2の半額以下で11月開始へ − @IT
http://www.atmarkit.co.jp/news/201109/06/sakura.html

One Click Install Software Library
WordPress 3.1.3 (Japanese)    Redmine 1.2-stable
http://www.fluxflex.com/library
0682nobodyさん2011/09/28(水) 06:06:05.40ID:???
Apache, MySQL, Ruby and Rails and required dependencies.
http://bitnami.org/stack/rubystack
0683nobodyさん2011/09/28(水) 15:05:01.90ID:???
>>667-672
0684nobodyさん2011/09/29(木) 00:25:58.66ID:???
スパムの合間を抜いて質問させてけろ

Rails3.1にてフォームボタンを押下した後、次のページに遷移するまで
そのボタンの横で
ビジーのインジケーターをくるくる回すにはどのような手順を踏めばいいかな?jquery?
0685nobodyさん2011/09/29(木) 01:21:33.83ID:???
jquery(javascript)の話だな
0686nobodyさん2011/09/29(木) 08:33:40.18ID:???
ボタンを押されたらインジケータを表示するだけじゃん
ページ移動するんだから後のことは考えなくていい
戻るボタン?知るか。
0687nobodyさん2011/09/29(木) 09:29:25.66ID:???
Heroku | Python and Django on Heroku
http://blog.heroku.com/archives/2011/9/28/python_and_django/
0688nobodyさん2011/09/29(木) 11:10:22.51ID:???
さくらVPSでDropbox - webネタ
http://d.hatena.ne.jp/R-H/20110928
0689nobodyさん2011/09/30(金) 11:15:59.92ID:???
ActiveRecordでのバイナリデータの扱いが上手くいかず教えてください。

require 'rubygems'
require 'active_record'
require 'open-uri'
ActiveRecord::Base.establish_connection( :adapter => 'sqlite3', :database => 'test.db')
class Download < ActiveRecord::Base ; end
ActiveRecord::Schema.verbose = false
ActiveRecord::Schema.define do
create_table "downloads", :force => true do |t|
t.column :image, :binary
end
end
record = Download.new
open('http://www.jreast.co.jp/map/pdf/map_tokyo.pdf') do |page|
image = page.read
File.open("image1.pdf",'w'){|fh| fh.puts image}
record.image = image
record.save
end
record = Download.first
File.open("image2.pdf",'w'){|fh| fh.puts record.image}

上のコードでimage1、image2は問題なくAcrobat等で開けます。ところが、
sqlite3 test.db 'select image from downloads where id = 1;' > image3.pdf
とシェルからやるとimage3はpdfとして認識されません(壊れている?)ActiveRecordのバイナリとsqlite3のblobの扱いの理解の足りなさに原因があるとは思いますが、image3をきちんと開くための方法を教えてください。
(要するにrubyであつかったバイナリデータを他の言語等で受け継いで扱いたいのです。)
環境はruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]、activerecord (3.0.1)、sqlite3 (3.6.12) OSX10.6です。
0690nobodyさん2011/09/30(金) 12:58:48.94ID:???
image3なんてどこにもないもんな
06916892011/09/30(金) 13:13:17.38ID:???
ちなみに以下のようにサイズが3049バイト大きくなってしまうので、マッピングのときに何かを追加したりしているのでしょうか?
あるいはリダイレクトの仕方に問題が?
201074 Sep 30 11:58 image1.pdf
201074 Sep 30 11:58 image2.pdf
204123 Sep 30 11:58 image3.pdf
0692nobodyさん2011/09/30(金) 14:44:53.90ID:???
sqlite知らんが、select文の結果が
バイナリじゃなくて文字に変換されてたりするんじゃないのか?
0693nobodyさん2011/09/30(金) 16:10:24.42ID:???
sqlite3 のコマンドラインで特定のカラムの値をそのまま出力する方法はなかったかと
(必ず整形が入る)

print Download.find(ARGV[0]).image

みたいなスクリプトを書いて、rails runner で動かすのが一番簡単かな
06946892011/09/30(金) 16:47:54.83ID:???
>>692>>693
適切なアドバイスありがとうございました。結局BLOBはバイナリそのままではないようですね。
同じSQLiteのDBをC言語などであつかうつもりですのでいったんBase64でエンコードしてから保存することにしました。
SQLiteの性質を十分には把握していなかったようです。あるいみActiveRecodeの楽さかげんが際立ってしまった。
0695nobodyさん2011/09/30(金) 17:00:09.32ID:???
「Google Analytics」リアルタイムアクセス解析に対応
http://netafull.net/marketing/038710.html
06966932011/09/30(金) 17:09:59.39ID:???
>>694
いや、BLOBが悪いんじゃなく、sqlite3 コマンドを使おうとしてるのが悪いと
言ってんだけど…
0697nobodyさん2011/09/30(金) 23:12:48.17ID:d8ot3xr3
bundle install --path vendor/bundle  さえしとけば
必要なものは優先的にvendorの中を覗きにいくようになるのでしょうか?
それともRails本体の中にあるgemを優先的に覗きにいくのでしょうか?
0698nobodyさん2011/09/30(金) 23:29:01.99ID:???
active scaffoldって3.1に対応してないよね?
残念だ
0699nobodyさん2011/09/30(金) 23:38:21.30ID:???
賢い皆様にお伺いしたいんだけど
管理者用のscaffoldへのアクセス制限は
どのような仕組みでかけてますか?
0700nobodyさん2011/10/01(土) 00:17:11.40ID:???
そもそもscaffoldを使わない
0701nobodyさん2011/10/01(土) 00:23:37.85ID:???
>>699の考えるscaffoldという概念は、実際と少しずれてるんじゃないだろうか
0702nobodyさん2011/10/01(土) 00:49:31.54ID:???
nginxの人だろ
0703nobodyさん2011/10/01(土) 02:48:44.76ID:ENlvmGfR
>>697
script/rails runner 'puts $:'
0704nobodyさん2011/10/01(土) 14:19:47.79ID:???
あの、大学がほとんどMacしか置いてないんでMacで勉強してるんですけど、ここで質問しても大丈夫ですかね?
0705nobodyさん2011/10/01(土) 14:23:39.48ID:???
Railsの事ならどうぞ
0706nobodyさん2011/10/01(土) 14:26:57.62ID:???
MacでのRails用環境構築とかかな?
OSのバージョンとかは書いてね
0707nobodyさん2011/10/01(土) 14:58:16.00ID:ENlvmGfR
Windowsの質問よりよほどマシ。
0708nobodyさん2011/10/01(土) 15:43:13.73ID:???
ありがとー
MacにphpMyAdminいれて鯖を作りたいです
どうすればいいですか?
0709nobodyさん2011/10/01(土) 15:47:47.53ID:???
>>708
自分のマシン?それとも共用?
0710nobodyさん2011/10/01(土) 15:55:30.50ID:ENlvmGfR
まてせめてRailsの質問にしろ。
0711nobodyさん2011/10/01(土) 16:20:48.80ID:???
まずターミナルを起動します。
0712nobodyさん2011/10/01(土) 16:42:59.87ID:???
>>699
ACL9とか使え。
0713nobodyさん2011/10/01(土) 18:41:50.31ID:???
>>709
共用です

他の人たちは黙っとけ
0714nobodyさん2011/10/01(土) 19:26:44.60ID:???
phpMyAdminの質問禁止。自分でどうにかしろ。
07157042011/10/01(土) 19:50:30.99ID:???
すいません遅くなりました、>>704の者です。

http://www.oiax.jp/rails/rails3.html を参考にして"第12回: ユーザー認証(1)"までなんとかたどり着いたのですが、
この第12回の中盤のDeviseをbundle installする過程でつまずきました。

http://www.oiax.jp/rails/rails3/authentication1.html にあるように
Gemfileに 「gem 'devise', '1.1.2'」の一文を追加し、ターミナルにてbundle installを実行したところ、
以下のようなエラーを吐いてしまいました。

「devise v1.1.2はこのバージョンのrubyに対応してないぞ」と言われてる気がするんですが、
これはrubyのバージョンを下げてしまうべきですか?
それとも対応した新しいバージョンのdeviseが出てたりするんですか?

初心者で申し訳ないですが、誰か分かる方いらっしゃいましたら教えてください。。

Ore-no-Imouto-no-MacBook-Pro:nchak hiro$ bundle install
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "bcrypt-ruby":
In snapshot (Gemfile.lock):
bcrypt-ruby (3.0.1)

In Gemfile:
devise (= 1.1.2) ruby depends on
bcrypt-ruby (~> 2.1.2) ruby

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
0716nobodyさん2011/10/01(土) 20:00:55.44ID:???
ruby のバージョンは?
あと、そのrubyってどうやって入れた?もしくは元から入ってたやつ?
07177042011/10/01(土) 20:16:43.45ID:???
「Ruby on Rails 3.1 を Mac OS X にインストールする手順をかなり丁寧に説明してみました - Rails 雑感 - Ruby on Rails with OIAX」
http://www.oiax.jp/rails/zakkan/rails_3_1_installation_on_macosx.html

railsの環境は上の記事を参考にして整えました。
当方の環境がOSX v10.7.1 Lionでしたので、"Rubyを更新"というステップは飛ばし、元から入っていたバージョンを使っています。

一応コマンドもやってみました。
$ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
0718nobodyさん2011/10/01(土) 20:52:12.94ID:ENlvmGfR
rubyのバージョンの問題ではなさそう。
bcrypt-ruby (暗号化に関するgem)の、
deviseが期待するバージョンでは条件を満たせないと言っている。

Rails 3.1 は ActiveModel の特定のバージョン (=3.1.0) のみを使う。
ActiveModel 3.1.0 は bcryt-ruby の特定のバージョン( ~> 3.0.0) を必要とする。

で、あなたの入れようとしたdevise は ~> 2.1.2 という条件の bcryp-ruby を
使うといっているわけだ。 ~> ってのは、ドットで区切った上位の数値が同じで
あれば、下の方のバージョンだけはより大きなものでもいい、という指定で、
残念ながら 3.x では ~> 2.1.2 という条件を満たせない(3は2より大きいが最上
位が違うのは受け入れられないので)

Rails 3.1.1 (rc2) は bcrypt-ruby を必須gemから外しているからなんとか
なるかもしれないけど… 勉強に rc ってのもな…
0719nobodyさん2011/10/01(土) 20:54:26.04ID:ENlvmGfR
最新のdevise は bcrypt-ruby ~> 3.0.0 になってるのね
https://github.com/plataformatec/devise/blob/master/devise.gemspec
0720nobodyさん2011/10/01(土) 21:01:28.61ID:???
Gemfileのバージョンの部分削ってから、bundle installした方がいい。
その記事と、もしかしたら挙動が違うかも知れんが。

あと今後の事を考えると、rubyはデフォルトのじゃなくて rvmで入れた方が良いかも。
0721nobodyさん2011/10/01(土) 21:03:44.28ID:???
ruby は1.9.2以上で
0722nobodyさん2011/10/01(土) 21:05:49.15ID:ENlvmGfR
ところで、Lion付属のRubyは日本人にとって非常に残念なバグがあるので、
その点でも、新しいの入れたほうがいいな。

$ /usr/bin/ruby -vKu -e 'p "あいうえお"'
ruby 1.8.7 (2010-01-10 patchlevel 249) [universal-darwin11.0]
"あいうえ¥343¥201¥212"

p250で直ってるところが残念すぐる。
0723nobodyさん2011/10/01(土) 21:22:06.54ID:???
-Ku って使った事ないから気がつかなかった。
日本語はpじゃなくてputsしてるし。
07247042011/10/01(土) 21:44:13.35ID:???
>>718-719
詳しくありがとうございます!
つまり、Railsを最新のRC版に更新したとしても、
Rubyじゃなくてbcrypt-rubyのバージョンをv3.0.0以下に下げなくてはいけないという事なんですね。。

>721
>>ruby は1.9.2以上で
やっぱ新しくすべきですか。
ちなみにv1.9.2とv1.9.3(RC1)のどちらがおすすめですか?
07257042011/10/01(土) 21:44:28.65ID:???
>>722
バグ!!なるほど・・・よく分からないけど

## test.rb ##
arr = Hash.new
arr["No-001"] = "春"; arr["No-002"] = "夏"; arr["No-003"] = "秋"; arr["No-004"] = "冬"
p(arr)
for n in arr; print("KEY:", n[0], " --> VALUE:", n[1], "\n"); end
## /test.rb ##

を実行すると、

$ ruby test.rb
{"No-001"=>"\346\230\245", "No-002"=>"\345\244\217", "No-003"=>"\347\247\213", "No-004"=>"\345\206\254"}
KEY:No-001 --> VALUE:春
KEY:No-002 --> VALUE:夏
KEY:No-003 --> VALUE:秋
KEY:No-004 --> VALUE:冬

って感じに、p(arr)の出力が数字になるのもRubyのバージョンの問題なんですかね?
07267042011/10/01(土) 21:45:08.63ID:???
>>720
Gemfileのバージョンの部分を削ったらとりあえずエラー出ずに通りました!!
$ bundle install
Fetching source index for http://rubygems.org/
Enter your password to install the bundled RubyGems to your system:
Using rake (0.9.2)
Using multi_json (1.0.3)
Using activesupport (3.1.0)
Using bcrypt-ruby (3.0.1)
Using builder (3.0.0)
Using i18n (0.6.0)
Using activemodel (3.1.0)
Using erubis (2.7.0)
Using rack (1.3.3)
Using rack-cache (1.0.3)
Using rack-mount (0.8.3)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.0.0)
Using actionpack (3.1.0)
Using mime-types (1.16)
07277042011/10/01(土) 21:47:11.49ID:???
Using polyglot (0.3.2)
Using treetop (1.4.10)
Using mail (2.3.0)
Using actionmailer (3.1.0)
Using arel (2.2.1)
Using tzinfo (0.3.30)
Using activerecord (3.1.0)
Using activeresource (3.1.0)
Using bundler (1.0.20)
Using coffee-script-source (1.1.2)
Using execjs (1.2.9)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using rdoc (3.9.4)
Using thor (0.14.6)
Using railties (3.1.0)
Using coffee-rails (3.1.1)
Installing orm_adapter (0.0.5)
Installing warden (1.0.5)
Installing devise (1.4.7)
Using jquery-rails (1.0.14)
Using json (1.6.1)
Using rails (3.1.0)
Using sass (3.1.7)
Using sass-rails (3.1.3)
Using sqlite3 (1.3.4)
Using sqlite3-ruby (1.3.3)
Using uglifier (1.0.3)
Using will_paginate (3.0.pre2)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
07287042011/10/01(土) 21:48:50.08ID:???
>>720
てかrvmというものがあるんですね!

ググってみたら http://gihyo.jp/dev/serial/01/ruby/0039 というページが出てきたんですけど、
よくわからないんですがこの通りにやればいいですか?
0729nobodyさん2011/10/01(土) 22:07:58.87ID:???
>>728
まあ、大体そんな感じ。
Lionでは、その記事のreadlineの部分は無視していい。
homebrew使ってるなら
$ brew install readline
しといても害は無い。どうせ他に何か入れた時に入るから。

ruby のバージョンは 1.9.2 と 1.9.3 と迷いどころだけど、1.9.3-head (もしくは1.9.2-head)としとけば良いような気もする。

あと毎回 rvm use するのが面倒なら、.rvmrc ファイルを作る。
前に挙げてた記事の通りやっているのだと、workディレクトリ作ってその下で作業員してるかも知れない。
その場合、
$ cd work
$ echo '1.9.3-head' > .rvmrc
$ cd ..
$ cd work
するとなんか聞かれるから、yと答えて。

そうするとworkにcd すれば自動で
1.9.3-head使うようになるから。
0730nobodyさん2011/10/01(土) 22:28:23.84ID:???
誰かactive-scaffold使ってる人いませんか?
■ このスレッドは過去ログ倉庫に格納されています