railscasts

Using Active Record Reputation System gem, no sorting happens when I sort by votes

允我心安 提交于 2019-12-10 07:45:09
问题 Following the RailsCast for the reputation system gem, I added the following code to my microposts_controller def index @microposts = Micropost.paginate(page: params[:page]).find_with_reputation(:votes, :all, order: "votes desc") @micropost = current_user.microposts.build end But no sorting happens in my index action aside from the default scope I set in my model In my micropost model I have class Micropost < ActiveRecord::Base belongs_to :user has_many :retweets has_reputation :votes, source

Rails 3 Nested Models unknown attribute Error

蓝咒 提交于 2019-12-09 00:06:39
问题 I have a model "Issue" and a nested Model "Relationship" In the issue.rb I have mentioned: has_many :relationships, :dependent => :destroy accepts_nested_attributes_for :relationships, :allow_destroy => true In relationship.rb I have mentioned: belongs_to :issue Following Ryan Bates Railcast#196 I have the following in my issues_controller: relationship = @issue.relationships.build However, I am encountering an error "unknown attribute: relationship" Am I doing something incorrectly here? I

Using AJAX to search, sort, and paginate in Rails 4

浪尽此生 提交于 2019-12-07 16:38:03
问题 I'm trying to do a real-time search in a Rails 4.0.1 application. I used the Railscasts #240 tutorial, but I am not getting the same results as the cast. It seems that my only issue is with the AJAX script, but I don't know why or how. app/views/subproducts/index.html.erb <%= form_tag subproducts_path, :method => 'get', :id => "subproducts_search" do %> <p> <%= text_field_tag :search, params[:search] %> <%= submit_tag "Search", :name => nil %> </p> <div id='subproducts'> <%= render

Using jCrop with cloudinary through rails 4 to crop before creating image

做~自己de王妃 提交于 2019-12-07 14:02:58
问题 I've been at this for some time now. I"m using cloudinary to upload photos and am trying to implement a cropping feature using jcrop on a photo create action. After I implemented cloudinary I followed railscasts #182 on Jcrop. I think I'm having problems getting the new cropped parameters (x,y,w,h) back to the uploader before the image is saved. Update: I'm not even getting the values put into the f.text_fields. When I move the cropper around, there should be new values right? Here's a pic of

Rails : User logged out after destroying an unrelated object with :remote => true

眉间皱痕 提交于 2019-12-07 09:28:26
问题 I'm following http://railscasts.com/episodes/250-authentication-from-scratch for simple authentication. It works as expected. I have a model in my app with the following partial : <%= content_tag_for(:li, post) do %> <%= link_to 'Delete', post, :confirm => 'Are you sure?', :method => :delete, :remote => true %> <% end %> It is called within index.html.erb as follows: <%= render :partial => @posts.reverse %> The destroy.js.erb is as follows, which is called if the object is successfully

How to use private submit to hide from feed?

与世无争的帅哥 提交于 2019-12-07 00:12:45
问题 In the valuations form there is a submit button and a <%= f.submit :private %> button. If private submit is clicked the submitted info will be hidden to other user's who view the profile. How can we also use <%= f.submit :private %> to hide submitted info from showing on the feed? activities/index.html.erb <h1>Feed</h1> <% @activities.each do |activity| %> <% if current_user == @user %> <%= render_activity activity %> <% else %> <%= render_activity activity %> #We'd need to make .public

undefined method `key?' for nil:NilClass

半城伤御伤魂 提交于 2019-12-06 04:03:06
问题 I'm new to Rails and was following Ryan Bate's tutorial on how to make a simple authentication system (http://railscasts.com/episodes/250-authentication-from-scratch?autoplay=true) and I was just going through it but got this error: ` NoMethodError in UsersController#new undefined method `key?' for nil:NilClass Rails.root: C:/Sites/authentication` I don't really know what this means since I'm just a beginner, but these are my files: users controller: class UsersController <

Using jCrop with cloudinary through rails 4 to crop before creating image

99封情书 提交于 2019-12-05 19:21:01
I've been at this for some time now. I"m using cloudinary to upload photos and am trying to implement a cropping feature using jcrop on a photo create action. After I implemented cloudinary I followed railscasts #182 on Jcrop. I think I'm having problems getting the new cropped parameters (x,y,w,h) back to the uploader before the image is saved. Update: I'm not even getting the values put into the f.text_fields. When I move the cropper around, there should be new values right? Here's a pic of what it looks like with empty fields: Also when I submit the photo, now I'm getting conflicting

Using Active Record Reputation System gem, no sorting happens when I sort by votes

孤人 提交于 2019-12-05 16:15:28
Following the RailsCast for the reputation system gem, I added the following code to my microposts_controller def index @microposts = Micropost.paginate(page: params[:page]).find_with_reputation(:votes, :all, order: "votes desc") @micropost = current_user.microposts.build end But no sorting happens in my index action aside from the default scope I set in my model In my micropost model I have class Micropost < ActiveRecord::Base belongs_to :user has_many :retweets has_reputation :votes, source: :user, aggregated_by: :sum default_scope -> { order('created_at DESC') } If I change the default

Private messages with Faye and Rails

可紊 提交于 2019-12-05 02:06:43
问题 I'm using the faye gem menitioned in the railscast allowing apps to push messages. Problem is it pushes messages to all chat clients that are open. I need them to be private. It's possible to get private messaging with faye but it's url based. For example all messages will be sent to site.com/foo . But, in my model the chat doesn't have a specific url. Because chat is just a collection of messages sent to you by that user. So if you're logged in as adam site.com/messages/eve would allow you