actionview

Passing block to label helper in rails3

夙愿已清 提交于 2019-12-01 04:30:46
I want to create label tag with some nested elements. I am using label helper and trying to pass inner html as block but generated HTML doesn't look as I expected. ERB: <span>Span element</span> <%= label("object", "method") do %> <span>Inner span</span> <% end %> HTML output: <span>Span element</span> <span>Inner span</span> <label for="object_method"> <span>Span element</span> <span>Inner span</span> </label> When I pass inner html using <% %> markups output is as it should be: ERB: <span>Span element</span> <%= label("object", "method") do %> <% raw '<span>Inner span</span>' %> <% end %>

Changing view on Menu Item in Action Bar

流过昼夜 提交于 2019-12-01 01:40:32
问题 I'm attempting to implement a refresh button in my app to allow a user to manually re-sync to a web server. The code works, but I'm having trouble figuring out the action views (at least, I think that's what I'm supposed to be using). My menu item is here: <item android:id="@+id/main_menu_refresh" android:enabled="true" android:icon="@drawable/refresh" android:orderInCategory="1" android:showAsAction="ifRoom" android:title="@string/refresh" android:actionViewClass="android.widget.ProgressBar"

Passing ActionView::Helpers::FormBuilder to a partial

拟墨画扇 提交于 2019-11-30 20:21:40
I am atempting to dinamically create form elements given a certain AJAX request. This is my setup: View: <%= link_to 'Next', check_unique_id_students_path, :remote => true %> <div id="guardian_student_details"></div> Controller: def check_unique_id @student = Student.new @this_form = ActionView::Helpers::FormBuilder.new(:student, @student, @template, {}, proc{}) end JS: jQuery("#guardian_student_details").html("<%=escape_javascript(render :partial => "student_details", :locals => { :s => @this_form }) %>"); Partial: <% puts s.text_field :first_name %> <% puts s.field_helpers %> For debugging

How can I use strip_tags in regular Ruby code (non-rails)?

百般思念 提交于 2019-11-30 08:04:06
I need to turn HTML into plain text. There's a nice function that does that in ActionView's SanitizeHelper, but I have trouble understanding how I can reference it and use it in a simple test.rb file. http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html I would like to be able to call strip_tags("<b>lol</b>") => "lol" The question is quite old, but I had the same problem recently. I found a simple solution: gem sanitize . It's light, works fine and has additional options if you need them. Sanitize.clean("<b>lol</b>") #=> "lol" ActiveSupport is the only Rails framework that

Passing ActionView::Helpers::FormBuilder to a partial

六眼飞鱼酱① 提交于 2019-11-30 03:56:51
问题 I am atempting to dinamically create form elements given a certain AJAX request. This is my setup: View: <%= link_to 'Next', check_unique_id_students_path, :remote => true %> <div id="guardian_student_details"></div> Controller: def check_unique_id @student = Student.new @this_form = ActionView::Helpers::FormBuilder.new(:student, @student, @template, {}, proc{}) end JS: jQuery("#guardian_student_details").html("<%=escape_javascript(render :partial => "student_details", :locals => { :s =>

How do I expire a view cached fragment from console?

别来无恙 提交于 2019-11-30 03:18:14
Something like Rails.cache.delete('site_search_form') doesn't seem to work. Is this possible? Thanks. Terry Cache fragment entries are created with a slightly different key than what you access with Rails.cache. Use expire_fragment instead (you can send it to a controller): http://api.rubyonrails.org/classes/ActionController/Caching/Fragments.html#M000438 ActionController::Base.new.expire_fragment(key) Rails.cache.delete "views/site_search_form" In Rails 5 I took the following steps to bust the cache without resorting to skip_digest: true . Our problem was that changing the value of I18n

How can I use strip_tags in regular Ruby code (non-rails)?

不问归期 提交于 2019-11-29 10:58:08
问题 I need to turn HTML into plain text. There's a nice function that does that in ActionView's SanitizeHelper, but I have trouble understanding how I can reference it and use it in a simple test.rb file. http://api.rubyonrails.org/classes/ActionView/Helpers/SanitizeHelper.html I would like to be able to call strip_tags("<b>lol</b>") => "lol" 回答1: The question is quite old, but I had the same problem recently. I found a simple solution: gem sanitize. It's light, works fine and has additional

搭建公司内部的问题需求跟踪平台(docker + actionview)

不羁的心 提交于 2019-11-29 07:43:09
1、安装docker 2、安装docker-compose 3、拉取代码 git clone https://github.com/lxerxa/actionview.git actionview 4、启动容器 cd actionview/docker mkdir data && mkdir data/db && mkdir data/uploads chmod -R 777 ./data docker-compose up -d 5、访问 http://localhost:8000/ 管理员登录:user: admin@action.view , password: actionview 6、演示地址 http://www.actionview.cn:8080/ 账号密码:hongzhong/actionview 7、官网 http://actionview.cn/ 来源: https://my.oschina.net/ydsjiang/blog/3103013

Rails form with multiple nested models causes issues with radio groups

試著忘記壹切 提交于 2019-11-29 07:23:28
I'm having a problem with nested model forms that contain radio buttons, when I have multiple models all the radio buttons are treated as being in the same group. My model contains a has_many relationship like this: class Order < ActiveRecord::Base has_many :order_items accepts_nested_attributes_for :order_items end Class OrderItem < ActiveRecord::Base belongs_to :order end I then have a partial that creates the OrderItem model form using <% fields_for "order[order_items_attributes][]", order_item do |f| %> And contained within this form is a group of radio buttons created inside a for loop

Rails passing form_for object to partial

隐身守侯 提交于 2019-11-29 02:10:30
问题 I would like to pass the form_for object to a partial: <%= form_for @price do |f| %> ... <%= render :partial => "price_page", :object => @price, :as => :f %> ... <% end %> When I call: f.radio_button Brings the error: undefined method `radio_button' for #<Price:0x3cb1ed0> How can I use f as I usually would in this partial? 回答1: Try passing form object as local <%= render :partial => "price_page", :locals=>{:f=>f} %> 回答2: You can pass form builder object as a local variable like below, <%=