Tag: strip

在Rails中创建新模型时,是否有一种在所有上使用strip的干燥方法:params?

我有一个表单来创建一个新的Contact模型。 我通过切割和粘贴手工输入值。 有时我最终会在左右两侧添加空白区域。 这是创建控制器中的内容(我有一个循环,检查我是否上传了一个vcard,显然,通常不会出现问题(尽管可能) – 但我的大问题是我自己输入它。 def create @contact = Contact.create(params[:contact]) unless @contact.vcard.path.blank? paperclip_vcard = File.new(@contact.vcard.path) @vcard = Vpim::Vcard.decode(paperclip_vcard).first @contact.title = @vcard.title @contact.email = @vcard.email @contact.first_name = @vcard.name.given @contact.last_name = @vcard.name.family @contact.phone = @vcard.telephone @contact.address.street1 = @vcard.address.street @contact.address.city = @vcard.address.locality @contact.address.state = @vcard.address.region @contact.address.zip = @vcard.address.postalcode @contact.company_name = @vcard.org.fetch(0) end @contact.user_id = current_user.id # makes […]

Bundler找不到gem mime-types的兼容版本

超级困惑的这个问题。 一切都在本地工作,但当我部署到Heroku时它会遇到这个错误: Bundler could not find compatible versions for gem “mime-types”: In Gemfile: rails (= 3.2.17) ruby depends on mime-types (~> 1.16) ruby stripe (>= 0) ruby depends on mime-types (2.3) 我已经尝试过gem在gemfile和命令行中安装mime-types 2.3并且都没有给出任何好的结果,尽管可能是因为我缺乏经验。 如果我有头发,我会把它拉出来! 同样,只有在部署到Heroku时才会出现此问题。 Everything bundle在本地安装和更新。