Ruby on Rails

Azuen

Member
Sep 22, 2004
133
0
0
Hi,

I am trying some development for rails but I've run into a few issues. I am using Instant Rails 2.0 (Rails version 2.0.2, Ruby version 1.8.6)

First, the scope of variables.

I have a page set up which is intended to display new information as it is added to the database table.
Code:
[i]content/view.html.erb[/i]
<%= periodically_call_remote(:update => "content", :frequency => 1, :position =>
"bottom", :url => {:controller => "content", :action => :get_new, :id => @content.id }) %>

Code:
[i]controllers/content_controller.rb[/i]
        before_filter :get_id

        #gets all the content with an id greater than the current id, reset id
        to newest
        def get_new
                @content = Content.find_all_by_id(params[:id], :order => "id DESC",
                :conditions => ["id > ?", @newest_id] )
                @newest = Content.find(:first, :order => "id DESC")
                @newest_id= @newest.id
        end

        #get the first id, so that all comments are retrieved on first call
        def get_id
                @newest = Content.find(:first, :order => "id ASC")
                @newest_id= @newest.id
        end
This code always updates with all the items in the database, as if the @newest_id wasn't being checked at all. Where should the id be stored, on the client? How can it be updated while a user views, but reset when the user returns or manually refreshes (F5) the page?

Second, I am attempting to allow tags on the pieces of content, however I want to try implement them myself with only basic functionality.

I have the following tables:
tag(id, name)
content_tag(tag_id, content_id)
content(id, title, image_url, image_text)

Pseudocode would be something like this, though I don't know how to implement it into Rails.
Code:
1. Parse the input from content_create view
2. Insert content into table
3.1. parse tags (strip by spaces, allow only 5)
3.2.1. for each tag
3.2.2. check for existence/uniqueness of name in tag table
3.2.3. if it doesn't exist, add it, otherwise do nothing
3.2.4. add tag_id and content_id into the content_tag table
3.2.5. end for loop
4. end

Third, I have to implement a search function. Is it possible to use auto_complete plugin to search through multiple tables for results to return in the auto_complete? For example autocomplete in a single search box on tag(name) and content(title).
 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |