Search Results

Search found 2 results on 1 pages for 'truthseekr'.

Page 1/1 | 1 

  • rails associations - How would you represent this relationship?

    - by truthSeekr
    Hello All, I am trying to figure out a best way to represent the following relationship. Newspaper-->has_many-->Articles Newspaper-->has_many--->Subscribers Subscribers are allowed to save the articles for their personal page. Two Questions: 1) How would the relationship look like in rails? How would the action 'save' look like? The following using has_many does not seem right to me: ArticleController < ApplicationController def save a = Article.find(101) @user.saved_articles << a end 2) Do I need a join table Saved_Articles that looked like this? Saved_Articles ---------------- user_id, article_id I am not sure how the has_many_through works. any advice is appreciated. thanks

    Read the article

  • will_paginate without use of activerecord

    - by truthSeekr
    I apologize if this is a trivial question or my understanding of rails is weak. I have 2 actions in my controller, index and refine_data. index fetches and displays all the data from a database table. refine_data weeds out unwanted data using regex and returns a subset of the data. Controller looks like: def index Result.paginate :per_page => 5, :page => params[:page], :order => 'created_at DESC' end def refine_data results = Result.all new_results = get_subset(results) redirect_to :action => 'index' end I would like to redirect the refine_data action to the same view (index) with new_results. As new_results are not from the database table (or model), how do I go about constructing my paginate?

    Read the article

1