Search Results

Search found 61 results on 3 pages for 'bgadoci'.

Page 3/3 | < Previous Page | 1 2 3 

  • remote_form_for in index.html.erb file not working w/ AJAX...Ruby on Rails...

    - by bgadoci
    Just curious if I am overlooking something simple here. I have deployed the remote_form_for in the show.html.erb code before to render comments on a post (project in this case) without a problem. I have moved this code to the index view and seems to degrade to the normal form_for action (page refresh). I am not getting any javascript errors so not sure what is wrong here. Here is my code: index.html.erb <% remote_form_for [project, Comment.new] do |f| %> <p> <%= f.label :body, "New Comment" %><br/> <%= f.text_area (:body, :class => "textarea") %> </p> <p> <%= f.label :name, "Name" %> (Required)<br/> <%= f.text_field (:name, :class => "textfield") %> </p> <p> <%= f.label :email, "Email" %> (Required but will not be displayed)<br/> <%= f.text_field (:email, :class => "textfield") %> </p> <p><%= f.submit "Add Comment" %></p> <% end %> CommentsController#create def create @project = Project.find(params[:project_id]) @comment = @project.comments.create!(params[:comment]) respond_to do |format| format.html { redirect_to projects_path } format.js end end /views/comments/create.js.rjs page.insert_html :bottom, :commentwrapper, :partial => @comment page[@comment].visual_effect :highlight page[:new_comment].reset page.replace_html :notice, flash[:notice] flash.discard /views/comments/_comment.html.erb <% div_for comment do %> <div id="commentwrapper"> <% if admin? %> <%=link_to_remote "X", :url => [@project, comment], :method => :delete %> <% end %> <%= h(comment.body) %><br/><br/> Posted <%= time_ago_in_words(comment.created_at) %> ago by <%= h(comment.name) %> <% if admin? %> | <%= h(comment.email) %> <% end %></div> <% end %>

    Read the article

  • auto_complete plugin error: Couldn't find Question with ID=auto_complete_for_tag_tag_name

    - by bgadoci
    I have successfully set up this plugin before so I am curious as to what I am doing wrong here. I have built the ability for users to add tags to questions. I am not using tagging plugin here but that shouldn't matter for this. With respect to the auto complete, I am trying to have the form located in the /views/questions/show.html.erb file access the Tags table and display entries in the tags.tags_name column. When I begin to type in the field I get the following error message: Processing QuestionsController#show (for 127.0.0.1 at 2010-05-31 15:22:20) [GET] Parameters: {"tag"=>{"tag_name"=>"a"}, "id"=>"auto_complete_for_tag_tag_name"} Question Load (0.1ms) SELECT * FROM "questions" WHERE ("questions"."id" = 0) ActiveRecord::RecordNotFound (Couldn't find Question with ID=auto_complete_for_tag_tag_name): app/controllers/application_controller.rb:15:in `init_data' For some reason I am actually passing the field name as the Question.id. The plugin set up is fairly simple as you add the following line to your controller: auto_complete_for :tag, :tag_name and the following line in your routes.rb file: map.resources :tags, :collection => {:auto_complete_for_tag_tag_name => :get } I have added the controller line to both my tags and questions controller and also mapped resources for both tags and questions in my routes.rb file: map.resources :tags, :collection => {:auto_complete_for_tag_tag_name => :get } map.resources :questions, :collection => {:auto_complete_for_tag_tag_name => :get } I have played around with removing either or of the above but can't seem to fix it. Any ideas what I am doing wrong here?

    Read the article

  • Passing user_id, site_id, and question_id to same table on create...

    - by bgadoci
    I can't seem to figure out how to do this. I am trying to pass four different variables to a single table. To be more specific I am trying to create a "like" in a likes table that also captures the site_id (like an answer), user_id, and the question_id. Here is the set up. class Like < ActiveRecord::Base belongs_to :site belongs_to :user belongs_to :question end I will spare you the reverse, has_many associations but they are there. Here is the likes controller where I think the problem is. class LikesController < ApplicationController def create @user = current_user @site = Site.find(params[:site_id]) @like = @site.likes.create!(params[:like]) @like.user = current_user @like.save respond_to do |format| format.html { redirect_to @site} format.js end end end This code successfully passes the like and site_id but after many different variations of trying I can't get it to pass the question id. Here is my form: /views/sites/_site.html.erb (though the partial is being displayed in the /views/questions/show.html.erb file). <% remote_form_for [site, Like.new] do |f| %> <%= f.hidden_field :site_name, :value => "#{site.name}" %> <%= f.hidden_field :ip_address, :value => "#{request.remote_ip}" %> <%= f.hidden_field :like, :value => "1" %> <%= submit_tag "^" , :class => 'voteup' %> <% end %>

    Read the article

  • Limiting a search to records from last_request_at...

    - by bgadoci
    I am trying to figure out how to display a count for records that have been created in a table since the last_request_at of a user. In my view I am counting the notes of a question with the following code: <% unless @questions.empty? %> <% @questions.each do |question| %> <%= h(question.notes.count) %> end end This is happening in the /views/users/show.html.erb file. Instead of counting all the notes for the question, I would only like to count the notes that have been created since the users last_request_at datetime. I don't neccessarily want to scope notes to display this 'new notes' count application wide, just simply in this one instance. To accomplish I am assuming I need to create a variable in the User#show action and call it in the view but not really sure how to do that. Other information you may need: class Note < ActiveRecord::Base belongs_to :user belongs_to :question end class Question < ActiveRecord::Base has_many :notes, :dependent => :destroy belongs_to :user end

    Read the article

  • Fetching only the first record in the table (via the view) without changing controller?

    - by bgadoci
    I am trying to only fetch the first record in my table for display. I am creating a site where a user can upload multiple images and attach to a post but I only want to display the first image view for each post. For further clarification posts belong_to projects. So when you are on the projects show page you see multiple posts. In this view I only want to display the first image for each post. Is there a way to do this in the view without affecting the controller (as later I want to allow users to browse all photos through the addition of a lightbox). Here is my /views/posts/_post.html.erb code: <% div_for post do %> <% post.photos.each do | photo | %> <%= image_tag(photo.data.url(:large), :alt => '') %> <%= photo.description %> <% end unless post.photos.first.new_record? rescue nil %> <%= link_to h(post.link_title), post.link %> <%= h(post.description) %> <%= link_to 'Manage this post', edit_post_path(post) %> <% end %> UPDATE: I am using a photos model to attach multiple photos to each post and using paperclip here.

    Read the article

  • Has anyone used a rails gem for lightbox functionality? If so which ones?

    - by bgadoci
    Trying to figure out what is the best solution for using lightbox in rails. I have a set up an application that has projects and posts belong_to project. A post can have multiple photos and I am successfully only displaying the first photo in the photos table in the projects show view for each post. I am now trying to allow the user to view the rest of the photos associated with a post through a lightbox feature. Any idea if there is a rails ready solution for something like this?

    Read the article

  • How can I order my entries by sum from a separate table?

    - by bgadoci
    I am wondering how I can order posts in my PostController#index to display by a column total in a separate table. Here is how I have it set up. class Post < ActiveRecord::Base :has_many :votes end and Class Vote < ActiveRecord::Base :belongs_to :post end I user can either vote up or down a particular post. I know there are likely better ways to do what I am currently doing but looking for a fix given my current situation. When a user votes up a post, a value of 1 is passed to the Vote Table via a hidden field. When a user votes down a post a value of -1 is passed to the same column (names vote). I am wondering how I can display my posts in order of the sum of the vote column (in the vote table) for a particular post. Another way to say that is, if a particular post has a net vote sum of 5, I want that to appear above a post with a net vote sum of 4. I am assuming that I need to affect the PostController#index action in some fashion. But not sure how to do that.

    Read the article

  • Displaying count for current_user 'likes' on a 'question' in questions/show.html.erb view

    - by bgadoci
    I have an application that allows for users to create questions, create answers to questions, and 'like' answers of others. When a current_user lands on the /views/questions/show.html.erb page I am trying to display the total 'likes' for all answers on that question, for the current_user. In my Likes table I am collecting the question_id, site_id and the user_id and I have the appropriate associations set up between user, question, answers and likes. I think I just need to call this information the right way, which I can't seem to figure out. All of the below is taking place in the /views/questions/show.html.erb page. I have tried the following: <% div_for current_user do %> You have liked this question <%= @question.likes.count %> times <% end %> Which returns all the 'likes' for the question but not filtered by current_user You have liked this question <%= current_user.question.likes.count %> times Which gives an error of 'undefined method `question' You have liked this question <%= @question.current_user.likes.count %> times Which gives an error of 'undefined method `current_user' I have tried a couple of other things but they don't make as much sense as the above to me. What am I missing?

    Read the article

  • auto_complete plugin error: Couldn't find Question with ID=auto_complete_for_...

    - by bgadoci
    I have successfully set up this plugin before so I am curious as to what I am doing wrong here. I have built the ability for users to add tags to questions. I am not using tagging plugin here but that shouldn't matter for this. With respect to the auto complete, I am trying to have the form located in the /views/questions/show.html.erb file access the Tags table and display entries in the tags.tags_name column. When I begin to type in the field I get the following error message: Processing QuestionsController#show (for 127.0.0.1 at 2010-05-31 15:22:20) [GET] Parameters: {"tag"=>{"tag_name"=>"a"}, "id"=>"auto_complete_for_tag_tag_name"} Question Load (0.1ms) SELECT * FROM "questions" WHERE ("questions"."id" = 0) ActiveRecord::RecordNotFound (Couldn't find Question with ID=auto_complete_for_tag_tag_name): app/controllers/application_controller.rb:15:in `init_data' For some reason I am actually passing the field name as the Question.id. The plugin set up is fairly simple as you add the following line to your controller: auto_complete_for :tag, :tag_name and the following line in your routes.rb file: map.resources :tags, :collection => {:auto_complete_for_tag_tag_name => :get } I have added the controller line to both my tags and questions controller and also mapped resources for both tags and questions in my routes.rb file: map.resources :tags, :collection => {:auto_complete_for_tag_tag_name => :get } map.resources :questions, :collection => {:auto_complete_for_tag_tag_name => :get } I have played around with removing either or of the above but can't seem to fix it. Any ideas what I am doing wrong here? UPDATE: My QuestionsController#show action is fishing posts by: @question = Question.find(params[:id])

    Read the article

  • Limiting records in a model action...

    - by bgadoci
    How do I limit the number of records that I am outputting with the following code to only 3 records: User.rb def workouts_on_which_i_commented comments.map{|x|x.workout}.uniq end def comment_stream workouts_on_which_i_commented.map do |w| w.comments end.flatten.sort{|x,y| y.created_at <=> x.created_at} end html.erb file <% current_user.comment_stream.each do |comment| %> ... <% end %> UPDATE: I'm using Rails 2.3.9

    Read the article

< Previous Page | 1 2 3