Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails - view turning complete white after refreshed or visited several times

I have a view page that will randomly turn into a blank white page after I have visited it a few times. If I change something in the view, it turns back to normal temporarily, but then after a few more page visits, the page turns white again. Also, it only happens in Safari. Here is the controller action for the page:

class ProjectsController < ApplicationController
    def show_current_projects_to_freelancer
        if current_user.type == 'Student'
            @projects = current_user.projects
            @schedules = current_user.projects.collect {|project| project.schedule}
        else
            redirect_to applicants_path, notice: 'Only Freelancers have access to this page.'
        end
    end
end

There are two models: Schedule and Project. Schedule belongs_To Project and Project has_one schedule. The routes for schedule and Project are nested like this:

get 'projects/current', to: 'projects#show_current', as: :current_freelancer_projects
resources :projects do
      resources :schedules
end 

I've changed my view several times. This happens regardless of whether there is content in the view or no content. Here is what the view looks like now:

<div style="color: black;">
<h3>Current freelancer Projects</h3>
    <table>
        <tr>
            <td>Project Name</td>
            <td>Employer Name</td>
            <td>Date of Bid</td>
            <td>rating</td>
            <td>Bid</td>
            <td>Tags</td>
            <td>Make Schedule</td>
        </tr>
    <% @projects.each do |project| %>
        <tr>
            <td><%= project.title %></td>
            <td><%= project.employer.email %></td>
            <td>date</td>
            <td>rating</td>
            <td>bid</td>
            <td>tags</td>
            <td><%= link_to 'Create Schedule', new_project_schedule_path(project.id, Schedule.new) %></td>
        </tr>
    <% end %>
    </table>
</div>

I can't imagine what is causing this. I know it has to be independent from the view because no matter how i change the view it still happens. Does anyone have any ideas?

Here are the logs when the page does not show up. When the page does show up, its too long.

Started GET "/current" for 127.0.0.1 at 2013-11-22 17:08:18 -0500
Started GET "/current" for 127.0.0.1 at 2013-11-22 17:08:18 -0500
  ActiveRecord::SchemaMigration Load (0.4ms)  SELECT "schema_migrations".* FROM "schema_migrations"
  ActiveRecord::SchemaMigration Load (0.4ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by ProjectsController#show_current_projects_to_freelancer as HTML
Processing by ProjectsController#show_current_projects_to_freelancer as HTML
  User Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 226 ORDER BY "users"."id" ASC LIMIT 1
  User Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 226 ORDER BY "users"."id" ASC LIMIT 1
  Project Load (3.3ms)  SELECT "projects".* FROM "projects" WHERE "projects"."student_id" = $1  [["student_id", 226]]
  Project Load (3.3ms)  SELECT "projects".* FROM "projects" WHERE "projects"."student_id" = $1  [["student_id", 226]]
  Employer Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 202]]
  Employer Load (1.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 202]]
  Employer Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 201]]
  Employer Load (0.5ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 201]]
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 201]]
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 201]]
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 201]]
  CACHE (0.0ms)  SELECT "users".* FROM "users" WHERE "users"."type" IN ('Employer') AND "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1  [["id", 201]]
  Rendered projects/show_current_projects_to_freelancer.html.erb within layouts/application (97.3ms)
  Rendered projects/show_current_projects_to_freelancer.html.erb within layouts/application (97.3ms)
   (0.9ms)  SELECT COUNT(*) FROM "relationships" WHERE "relationships"."student_id" = $1 AND "relationships"."state" = 'active'  [["student_id", 226]]
   (0.9ms)  SELECT COUNT(*) FROM "relationships" WHERE "relationships"."student_id" = $1 AND "relationships"."state" = 'active'  [["student_id", 226]]
  Profile Load (1.0ms)  SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = $1 ORDER BY "profiles"."id" ASC LIMIT 1  [["user_id", 226]]
  Profile Load (1.0ms)  SELECT "profiles".* FROM "profiles" WHERE "profiles"."user_id" = $1 ORDER BY "profiles"."id" ASC LIMIT 1  [["user_id", 226]]
  Rendered layouts/_ssi_header_inner.html.erb (69.1ms)
  Rendered layouts/_ssi_header_inner.html.erb (69.1ms)
  Rendered layouts/_ssi_footer.html.erb (0.3ms)
  Rendered layouts/_ssi_footer.html.erb (0.3ms)
Completed 200 OK in 547ms (Views: 384.9ms | ActiveRecord: 17.2ms)
Completed 200 OK in 547ms (Views: 384.9ms | ActiveRecord: 17.2ms)
like image 229
Philip7899 Avatar asked Nov 02 '22 10:11

Philip7899


2 Answers

The problem was the cache. By disabling the cache, I was able to fix the problem.

like image 65
Philip7899 Avatar answered Nov 09 '22 16:11

Philip7899


Looks like a WebKit bug; it's happening with a lot of people even in iOS. https://bugs.webkit.org/show_bug.cgi?id=32829

like image 21
Arthur Corenzan Avatar answered Nov 09 '22 15:11

Arthur Corenzan