actionview

rails simple_nested_form_for fields_for wrong number of arguments

时间秒杀一切 提交于 2019-12-08 16:37:43
问题 So I'm building a form in rails 3.1, using <%= simple_nested_form_for(@person, :url => collection_url, :html=>{:multipart => true}) do |f| %> <%= render :partial => "form", :locals => { :f => f } %> <% end %> but this line in the partial is causing the problem: <h2>Badges</h2> <ul id="certifications"> // this following line is raising the error "wrong number of arguments (4 for 3)" <%= f.fields_for :certifications do |certification_form| %> <%= render :partial => 'certification', :locals => {

Rails form_tag form writing - with non-active record model

♀尐吖头ヾ 提交于 2019-12-08 16:29:35
问题 I'm somewhat of a Rails newbie. I'm writing a couchrest-rails app, so am not using activerecord for this model. I just figured out that that means that form_for(@model) won't work. I'm trying to work out how to use form_tag -- but most of the examples don't involve new & create actions. This is wrong: <h1>New article</h1> <% form_tag new_article_url(@article), :method => :post do |f| %> <%= f.error_messages %> <p> <%= f.label :title %><br /> <%= f.text_field :title %> </p> <p> <%= f.submit

Launching a file using ACTION_VIEW Intent Action

强颜欢笑 提交于 2019-12-08 03:04:26
问题 I have the following code to launch a file : try { path = fileJsonObject.getString("filePath"); if (path.indexOf("/") == 0) { path = path.substring(1, path.length()); } path = root + path; final File fileToOpen = new File(path); if (fileToOpen.exists()) { if (fileToOpen.isFile()) { Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW); myIntent.setData(Uri.parse(path)); final String pathToCheck = new String(path); pathToCheck.toLowerCase(); if (pathToCheck.endsWith(".wav") ||

Rails XML builder with no pretty-printing (i.e. minified XML)

一世执手 提交于 2019-12-07 15:52:16
问题 I am using Builder::XmlMarkup to produce data structures in XML format for a RESTful API server. Recently, I discovered a bug where the pretty-printing from Builder::XmlMarkup produced an element full of whitespace text instead of an empty element as it should. For example, this code: xml.outertag do xml.list do # Some code which loops through a list end end is producing: <outertag> <list> </list> </outertag> When the inner list is an empty list, the element must be empty—i.e. <list/> or

Give a 404 instead of a 500 error for missing templates

烂漫一生 提交于 2019-12-07 07:38:49
问题 I have a Rails 3.0 app (working on a 3.2 upgrade) and whenever someone requests a template that doesn't exist it gives a 500 error in production. For instance mysite.com/blog_posts/532 sends the post with ID 532 back as HTML no problem, but if for some reason mysite.com/blog_posts/532.txt is requested, the app raises a 500 ActionView::MissingTemplate error. This shouldn't happen, because the template shouldn't be there in the first place. It should more properly be a 404 error, or perhaps

Rails: execution expired on time_zone_select

假装没事ソ 提交于 2019-12-07 06:09:18
问题 The following exception comes up intermittently: An ActionView::Template::Error occurred execution expired vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' This is the full trace: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2

Launching a file using ACTION_VIEW Intent Action

耗尽温柔 提交于 2019-12-06 09:48:52
I have the following code to launch a file : try { path = fileJsonObject.getString("filePath"); if (path.indexOf("/") == 0) { path = path.substring(1, path.length()); } path = root + path; final File fileToOpen = new File(path); if (fileToOpen.exists()) { if (fileToOpen.isFile()) { Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW); myIntent.setData(Uri.parse(path)); final String pathToCheck = new String(path); pathToCheck.toLowerCase(); if (pathToCheck.endsWith(".wav") || pathToCheck.endsWith(".ogg") || pathToCheck.endsWith(".mp3") || pathToCheck.endsWith(".mid") || pathToCheck

How to pass multiple locals to a nested partial

倾然丶 夕夏残阳落幕 提交于 2019-12-06 06:24:31
问题 This should be extremely straightforward and well documented, and I've done it several times, although there's something that's still killing me. I have a structure of partials calling nested partials. At some point one render call needs to pass an extra variable to the partial, although the rendering of the partial fails with a: undefined local variable or method `<variable name>' for #<#<Class:....> Here's my code for calling the render : = f.simple_fields_for :orders do |c| = render

Give a 404 instead of a 500 error for missing templates

感情迁移 提交于 2019-12-05 15:28:37
I have a Rails 3.0 app (working on a 3.2 upgrade) and whenever someone requests a template that doesn't exist it gives a 500 error in production. For instance mysite.com/blog_posts/532 sends the post with ID 532 back as HTML no problem, but if for some reason mysite.com/blog_posts/532.txt is requested, the app raises a 500 ActionView::MissingTemplate error. This shouldn't happen, because the template shouldn't be there in the first place. It should more properly be a 404 error, or perhaps just show the HTML template. How can I make the app either show a 404 error for all missing-template

Rails: execution expired on time_zone_select

我们两清 提交于 2019-12-05 11:15:42
The following exception comes up intermittently: An ActionView::Template::Error occurred execution expired vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' This is the full trace: vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `require' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:251:in `block in require' vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency' vendor/bundle/ruby/1.9.1/gems