I am new in ruby and trying to post comments by the user in services.

 They were successfully posted in a services view page and  stored in  
database as well but i want to check whether  the comment by the user is 
spam or not.

I my service controller, i am posting the comment in **updating comment 
attributes method** then  saving those in **update method**

 What i am doing is listed below:-

 

    def update_comment_attributes
    params[:service][:comments_attributes].each{ |k, v| v.merge!(user_id:   
session[:user_id]).merge!(author: User.where(:id => 
session[:user_id]).pluck(:name).first ).merge!(author_email: User.where(:id 
=> session[:user_id]).pluck(:email).first )}  if params[:service] && 
params[:service][:comments_attributes]
    end

here is update :-


    def update
    respond_to do |format|
      if @service.update(service_params)
    
    
        @comment = Comment.find_by(service_id:@service.id, user_id: 
session[:user_id])
            if @comment.spam?
                @comment.is_spam = 'Y'
                @comment.aki_response = @comment.akismet_response
                @comment.update_attribute(is_spam: 'Y')
            else
                @comment.is_spam = 'N'
                @comment.aki_response = @comment.akismet_response
                @comment.save
                @comment.update_attribute(:is_spam, 'N')

            end
    
        format.html { redirect_to @service, notice: 'Service was 
successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: 'edit' }
        format.json { render json: @service.errors, status: 
:unprocessable_entity }
      end
    end
     end

now as i am commenting my comments do save but it didn't check whether it 
is spam or not ..tried a lot got failed..

Thanks in advance 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/16a735e7-ee9e-4b51-a6a6-35bba06f2a1c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to