Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: lschule/rssYeah
base: 7bec517acc
...
head fork: lschule/rssYeah
compare: 258829c525
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 8 files changed
  • 0 commit comments
  • 1 contributor
View
14 app/controllers/saved_searches_controller.rb
@@ -3,6 +3,7 @@ class SavedSearchesController < ApplicationController
# GET /saved_searches.json
def index
@saved_searches = SavedSearch.all
+
respond_to do |format|
format.html # index.html.erb
format.json { render json: @saved_searches }
@@ -14,24 +15,12 @@ def index
def show
@saved_search = SavedSearch.find(params[:id])
-# @saved_search.last_access = Time.now
-# @saved_search.save()
-# redirect_to saved_searches_url and return
-
respond_to do |format|
format.html # show.html.erb
format.json { render json: @saved_search }
end
end
-# def access
-# @saved_search = SavedSearch.find(params[:id])
-
-# @saved_search.last_access = Time.now
-# @saved_search.save()
-# redirect_to saved_searches_url and return
-# end
-
# GET /saved_searches/new
# GET /saved_searches/new.json
def new
@@ -52,6 +41,7 @@ def edit
# POST /saved_searches.json
def create
@saved_search = SavedSearch.new(params[:saved_search])
+ @saved_search.user = current_user
respond_to do |format|
if @saved_search.save
View
5 app/models/saved_search.rb
@@ -1,12 +1,13 @@
class SavedSearch < ActiveRecord::Base
+ belongs_to :user
def articles
- search_params = {:query => query, :after => last_access}
+ search_params = {:query => query, :after => last_access, :feeds => user.feeds.collect { |item| item.id }}
Article.search(search_params)
end
def count
- search_params = {:query => query, :after => last_access}
+ search_params = {:query => query, :after => last_access, :feeds => user.feeds.collect { |item| item.id }}
Article.count(search_params)
end
View
1  app/models/user.rb
@@ -2,5 +2,6 @@ class User < ActiveRecord::Base
has_and_belongs_to_many :feeds
has_many :user_articles
has_many :articles, :through => :user_articles
+ has_many :saved_searches
acts_as_authentic
end
View
1  app/views/channels/index.html.erb
@@ -11,6 +11,7 @@
<td>(<%= channel.count %>)</td>
<td><%= link_to channel.query, channel_path(channel) %></td>
<td>we could also list facets here, i.e. how many news per feed</td>
+ <td><%= link_to 'edit saved search', edit_saved_search_path(channel) %></td>
</tr>
<% end %>
</table>
View
3  app/views/saved_searches/index.html.erb
@@ -2,8 +2,8 @@
<table>
<tr>
+ <th>Owner</th>
<th>Query</th>
- <th>(New)</th>
<th>Last access</th>
<th></th>
<th></th>
@@ -12,6 +12,7 @@
<% @saved_searches.each do |saved_search| %>
<tr>
+ <td><%= saved_search.user.username %></td>
<td><%= saved_search.query %></td>
<td><%= saved_search.last_access %></td>
<td><%= link_to 'View Articles', channel_path(saved_search) %></td>
View
5 app/views/saved_searches/show.html.erb
@@ -1,6 +1,11 @@
<p id="notice"><%= notice %></p>
<p>
+ <b>Owner:</b>
+ <%= link_to @saved_search.user.username, user_path(@saved_search.user) %>
+</p>
+
+<p>
<b>Query:</b>
<%= @saved_search.query %>
</p>
View
6 db/migrate/20120401154108_add_user_id_to_saved_search.rb
@@ -0,0 +1,6 @@
+class AddUserIdToSavedSearch < ActiveRecord::Migration
+ def change
+ add_column :saved_searches, :user_id, :integer
+
+ end
+end
View
3  db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120331132621) do
+ActiveRecord::Schema.define(:version => 20120401154108) do
create_table "articles", :force => true do |t|
t.string "name"
@@ -43,6 +43,7 @@
t.datetime "last_access"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
+ t.integer "user_id"
end
create_table "smart_categories", :force => true do |t|

No commit comments for this range

Something went wrong with that request. Please try again.