ruby-on-rails-3.2

Dynamic creation of Multiple NVD3 charts with rails partial

限于喜欢 提交于 2019-12-12 04:49:59
问题 I have a page which I am trying to show multiple NVD3 charts on tabs. I see on the NVD3 site that they store all chart names ahead of time but I am not sure how I should do this. I have graph models which get stored in the database and then my page must dynamically render all of the charts and appropriate javascript on the fly. So far only the last graph constructed shows :( I render this partial for each graph <%if graph.present?%> <%@graph = graph%> <%end%> <%if @graph.data.empty?%> <%=

Ruby on Rails page does not refresh when form is posted

梦想与她 提交于 2019-12-12 04:47:25
问题 In the code sample posted below, I am trying to allow the user of the page to filter out which projects should be displayed by user. I am able to successfully filter the results by manually modifying the parameters passed in the address bar. But when I click the Filter button on the page it does nothing at all. It should refresh the page with the new parameters being passed when the button is pressed. Any ideas as to why this happens? Do I need to add anything in my controller? View: = form

rails 3.2 skip paperclip attachment presence validation on edit action

佐手、 提交于 2019-12-12 04:46:09
问题 I am new to Rails and i'm working on my first rails application that uses paperclip for attachments and i'm validating the presence of attachment using validates_attachment :avatar, presence: true which is working perfectly well on create action, but when a user is editing his account settings and doesn't upload a new avatar, there is an error for not having avatar uploaded but i want to skip that validation on edit and only validate on edit if user uploads a new one to replace existing one.

Rails Actionmailer to email specific group of users based on User attribute being included in array

这一生的挚爱 提交于 2019-12-12 04:44:51
问题 I have a Document model with a string column access and a User model with a string column team . In a Document I can enter an array of items for access such as "staff, sales, manager". Meanwhile, a User has only one item under team . I am trying to send emails to specific Users based on whether or not for each user.team is included in the array for Document.access . For example if Document.access = "sales, management" , only Users with team = "sales" or team = "management" will be sent the

Image invalid on facebook/twitter user image uploading to S3

元气小坏坏 提交于 2019-12-12 04:33:16
问题 I'm trying to upload to amazon s3 an existing image on facebook or twitter from an user that has just signed up in my application, but some validation don't let me save the user object, throws: Image is invalid. I thought that was for my extension_white_list but I removed it and it's keeping saying Image is invalid. This it's not an error, it's just a message from a validation on carrierwave I think, even if the image url string is correct. AvatarUploader # encoding: utf-8 class

How can I hide a column in a jQuery datatables based on a user role

强颜欢笑 提交于 2019-12-12 04:20:53
问题 I have a jQuery datatables implemented and it's working just fine. However, based on a user role, I would like to hide a column. To fix this, in Rails, I can set the conditional within a view/template. But that doesn't' work because on each request I get an alert telling me about for how many rows data is missing to be pulled into. Any ideas as to how to fix this? Much appreciated. Alek 来源: https://stackoverflow.com/questions/12574635/how-can-i-hide-a-column-in-a-jquery-datatables-based-on-a

Rails Cascading Drop Down List: Change Drop down menu into Text Field based on Previous Drop Down Option Selected

雨燕双飞 提交于 2019-12-12 04:18:33
问题 In my Rails Application I have a Country Select Option Drop down list using the country_select gem,and next to the country select drop down there is another dropdown to display the states in "US" like the code bellow: CODE OF COUNTRY SELECT DROP DOWN <div class="row"> <div class="form-group"> <%= f.label :country,'Country', class:"control-label"%> <%= f.country_select(:country , {priority_countries: [ "US"]} ,{class: "form-control"}) %> </div> </div> CODE OF STATE SELECT DROP DOWN <%= f.label

Adding a JOIN between two tables

て烟熏妆下的殇ゞ 提交于 2019-12-12 03:53:37
问题 Here is the classes I have: Model Organization has_many Students Model Student has_many Classes belongs_to Organization Model Class a field named : price belongs_to Student scope :top_expensive_classes, joins(:students).order('price DESC') Now I want to list the top 10 expensive classes At least the first problem I have is that in the params I have the organization_id to filter based on that But I write my controller like this which does NOT work because it thinks it should find organization

Rails: prevent submitting form if field is blank

点点圈 提交于 2019-12-12 03:49:08
问题 I am creating product page, where user can upload more than one photo of product. To create and edit product, i am rendering a form file. For uploading photos, i have used nested_fields for photos in the form of the product. Here is how photo code in the form looks like: <%= f.fields_for :photos do |photo| %> <%= image_tag photo.object.avatar.url(:thumb), unless f.object.new_record? or photo.object.new_record? %> <%= photo.file_field :avatar, :style => "none" %> <%= photo.link_to_remove

how to use ajax response back in your view page?

只愿长相守 提交于 2019-12-12 03:43:37
问题 I have this as my view page <html> <head> <script> function submit_form() { $('#my_form').submit(); } </script> </head> <body> <div class="container"> <%= form_tag({:action => 'submit_form'}, :remote => true,:method=>:post,:id => 'my_form',:class => 'my_form_class') do %> <%= select(:grade,:id,@distinct_grade_list,{},:onchange => "submit_form()")%> <%= select(:period,:id,@distinct_period_list)%> <% end %> <br/> <div id="farzi2" style="border: 3px solid blue;margin-top: 20px"> <%= select(