actionview

How to open a file in Android via an Intent

橙三吉。 提交于 2019-12-23 06:54:13
问题 how can I open a file that has been previously stored in the "privat" filesystem? The file is being downloaded by a webservice and should be stored on local fs. I got a "strange" error when trying to open the file via an Intent (Action_View). Although the file is present in the filesystem (saw the file in the file explorer in emulator/eclipse) it won't be shown in the calling galery activity that is launched. Instead of the picture the galery shows a black screen with not content in there

Android : URI for open an image with ACTION View

戏子无情 提交于 2019-12-20 03:03:52
问题 This is the code protected static final String DIR_IMAGE = "/data/data/it.android.myprogram/images/"; Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); Uri u = Uri.fromFile(destinationFile); intent.setDataAndType(u, "image/*"); startActivity(intent); the file to open is into /data/data/it.android.myprogram/images if I do : File dir = new File(DIR_IMAGE); String[] files = dir.list(); The var files contain all files but when I start intent.setDataAndType(u,

How to render images in rails3 select

邮差的信 提交于 2019-12-20 01:42:21
问题 I want to render dropdown list in form with images as options. How to achieve this in rails3? 回答1: I like the msdropdown. You can add the path for the image in the title tag: <select> <option value="1" title="#path for the image">first</option> <option value="2" title="#path for the image">second</option> ... </select> In Rails, you can add the title doing something like: <%= f.select(:yourcolumn, Model.all.map{|p| [p.name, p.id, :title => p.image_url(:thumb)]} I have faced a similar problem

Passing block to label helper in rails3

爱⌒轻易说出口 提交于 2019-12-19 07:55:25
问题 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

Rails form with multiple nested models causes issues with radio groups

一笑奈何 提交于 2019-12-18 05:08: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

Rails: Should partials be aware of instance variables?

旧时模样 提交于 2019-12-17 17:26:17
问题 Ryan Bates' nifty_scaffolding, for example, does this edit.html.erb <%= render :partial => 'form' %> new.html.erb <%= render :partial => 'form' %> _form.html.erb <%= form_for @some_object_defined_in_action %> That hidden state makes me feel uncomfortable, so I usually like to do this edit.html.erb <%= render :partial => 'form', :locals => { :object => @my_object } %> _form.html.erb <%= form_for object %> So which is better: a) having partials access instance variables or b) passing a partial

Render default template on MissingTemplate Errors

蹲街弑〆低调 提交于 2019-12-11 10:07:35
问题 How can I catch the ActionView::MissingTemplate errors in Rails? For example, my PeopleController has an Index method, but it doesn't need a template. When someone browses to root_url/people they get the default static error template. And that's not the only controller with the issue; I want all missing template errors to redirect the user to my custom view. How to catch the exception? How to render a view afterwards? Rails version - 3.0.19 Thanks in advance! 回答1: Possible duplicate of:

Rails 4.2: Unknown Attribute or Server Error in Log

我的梦境 提交于 2019-12-10 10:58:13
问题 I have a form with a select_tag and options_from_collection_for_select that I can't seem to get to pass. In the view, when the upload id is set to uploadzip_id I get a 302 redirect and when it's set to uploadzip_ids , I get a Unknown Attribute error. I'm a bit confused as I have my relationship set up along with the foreign key. I do have another model with checkboxes called Uploadpdf that works fine. Here is the set up.. class Campaign < ActiveRecord::Base has_one :uploadzip end class

Rails3 button_to is calling POST action, trying to call PUT action

与世无争的帅哥 提交于 2019-12-09 15:57:06
问题 I have a button_to that I want to perform a PUT action (there is only one thing that can be updated about this resource - it will be updated as being 'acknowledged', so there are no other form fields associated with firing the action). This is in my view (the controller is given explicitly because the button is on a view that belongs to another controller): <%= button_to "Acknowledged", :controller => 'practice_sessions', :id => @practice_session.id, :method => :put %> In my routes file, the

Using rails_admin with rails_api

泄露秘密 提交于 2019-12-09 09:37:44
问题 I originally posted this as an issue on rails_api GitHub, but am now posting it here due to inactivity. I'm trying to use rails_admin with a Rails 5 API application. I included extra ActionController modules up to the point that I can either have a functioning rails_admin panel or working API requests. The issue seems to be that rails_admin depends on ActionView::Layouts , which after included causes issues for API requests. Gemfile: gem 'rails', '>= 5.0.0.beta3', '< 5.1' ... gem 'rack-pjax',