activescaffold / active_scaffold

Save time and headaches, and create a more easily maintainable set of pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read, update, delete) user interface needs, leaving you more time to focus on more challenging (and interesting!) problems.
MIT License
1.09k stars 327 forks source link

clicking on links doesn't refresh the page #83

Closed khelal closed 12 years ago

khelal commented 12 years ago

Hello, we are running the latest AS off master on a Rails 3.1.1 application and having a problem with the links.

Here's a screenshot of the actual table: AS Problem

The problem is that clicking on any links (show, clicking on the reference, company or name) actually launches the query, but the result is not show (the page does not refresh). Here is the rails log:

Started GET "/en/guru/tenders/2" for 127.0.0.1 at Mon Oct 31 19:03:22 +0400 2011
  Processing by Admin::TendersController#show as JS
  Parameters: {"id"=>"2", "locale"=>"en"}
  AdminUser Load (0.5ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 1 LIMIT 1
  Tender Load (0.5ms)  SELECT "tenders".* FROM "tenders" WHERE "tenders"."is_deleted" = 'f' AND "tenders"."id" = 2 LIMIT 1
Rendered admin/tenders/_overview.html.haml (0.3ms)
  Company Load (0.6ms)  SELECT "companies".* FROM "companies" WHERE "companies"."id" = 10000 LIMIT 1
  TenderPosting Load (0.2ms)  SELECT "tender_postings".* FROM "tender_postings" WHERE "tender_postings"."id" = 2 LIMIT 1
Rendered admin/tenders/_sidebar.html.haml (11.4ms)
Rendered admin/tenders/show.html.haml within layouts/admin (17.4ms)
Completed 200 OK in 98ms (Views: 85.8ms | ActiveRecord: 6.7ms)

Any ideas?

scambra commented 12 years ago

What browser?

scambra commented 12 years ago

Anyway, if there are some bug probably is in browser accept header or rails intrepeting it. You can test it with a sample app, without active_scaffold, add an action with respond_to block for html and js and add a link with :remote => true

khelal commented 12 years ago

Happens in at least Chrome (15.0.874.106) and Firefox (6.0.2).

scambra commented 12 years ago

Can you reproduce it in a sample app without active_scaffold? It's working here with Chrome 15 Also, try to reproduce it in a empty application with active_scaffold, with no customization

khelal commented 12 years ago

Ok I will try but might take some time. We are using AS as the way to display backend info in a pretty big app and all the other links work well (both inside the actual app and in sidebar of the admin pages).

AS Problem

scambra commented 12 years ago

Does links working use AJAX too?

khelal commented 12 years ago

Nope. they're all regular links.

scambra commented 12 years ago

Then it isn't relevant, your activescaffold broken links are remote links which use AJAX

khelal commented 12 years ago

fair enough. So how can we troubleshoot this?

Karim HELAL General Manager @ monaqasat.com http://www.monaqasat.com *

* The leading eTendering solution for the MENA region.

m: +971.50.641.7143 | t: +971.2.635.5775 | f: +971.2.635.5776 twitter: @monaqasat http://www.twitter.com/monaqasat | facebook: monaqasat http://www.facebook.com/monaqasat

On Wed, Nov 9, 2011 at 3:01 PM, Sergio Cambra < reply@reply.github.com>wrote:

Then it isn't relevant, your activescaffold broken links are remote links which use AJAX


Reply to this email directly or view it on GitHub:

https://github.com/activescaffold/active_scaffold/issues/83#issuecomment-2679961

scambra commented 12 years ago

Have you set config.show.link.page = true? Because you should get something like this: Rendered /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/active_scaffold-3.1.6/frontends/default/views/_show_columns.html.erb (48.5ms) Rendered /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/active_scaffold-3.1.6/frontends/default/views/_show.html.erb (51.9ms) Rendered /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/active_scaffold-3.1.6/frontends/default/views/_messages.html.erb (0.3ms) Rendered /opt/ruby-enterprise/lib/ruby/gems/1.8/gems/active_scaffold-3.1.6/frontends/default/views/_list_inline_adapter.html.erb (2.3ms)

Rendering of _list_inline_adapter and _show partial. But you get rendering of show view with layout. Also, have you overrided some methods in your controller?

khelal commented 12 years ago

Here's my entire controller for the Companies view:

class Admin::CompaniesController < Admin::AdminController
  before_filter :authenticate_admin_user!

  active_scaffold :company do |config|
    config.actions.exclude :create, :search
    config.actions.add :field_search
    config.field_search.columns = [:license_number, :name, :email]
    config.field_search.human_conditions = true
    config.list.always_show_search = true

    config.show.link.inline = false
    config.update.link.inline = false

    config.list.sorting = { :name => :asc }

    config.columns[:license_number].set_link "show", :inline => false
    config.columns[:name].set_link "show", :inline => false
    config.columns[:license_number].label = "License"

    # Configuration for List
    config.list.columns = [:id, :license_number, :name, :phone, :email, :membership]
  end

  def show
    @company = Company.find(params[:id])
  end

  def edit
    @company = Company.find(params[:id])
  end

  def update
    @company = Company.find(params[:id])

    respond_to do |format|
      if @company.update_attributes(params[:company])
        flash[:notice] = "Company <b>#{@company.name}</b> was successfully updated."
        format.html { redirect_to edit_admin_company_path(@company.id) }
      else
        format.html { render :action => "edit" }
      end
    end
  end

  def approve
    @company = Company.find(params[:id])

    if @company.approve!
      flash[:notice] = "Company '#{@company.name}' has been approved!"
    else
      flash[:error] = "Company '#{@company.name}' could not be approved!"
    end
    redirect_to :back
  end

  def start_review
    @company = Company.find(params[:id])

    # FIXME: RR: Fire email to the company users about this.

    if @company.start_review!
      flash[:notice] = "Company '#{@company.name}' is now under review."
    else
      flash[:error] = "Company '#{@company.name}' could not start being reviewed due to an error. Please try again."
    end

    redirect_to :back
  end

  def reject
    @company = Company.find(params[:id])

    # FIXME: RR: Fire email to the company users about this.
    if @company.reject!
      flash[:notice] = "Company '#{@company.name}' has been rejected."
    else
      flash[:error] = "Company '#{@company.name}' could not be rejected. Please try again."
    end
    redirect_to :back
  end

  protected

  def beginning_of_chain
    case params[:v]
      when 'new'
        active_scaffold_config.label = "Newly Registered Companies"
        super.with_state(:registered)
      when 'new_ok'
        active_scaffold_config.label = "Newly Registered Companies with Full Documentation"
        super.with_state(:registered).stamp_file_size_not_null.license_file_size_not_null.logo_file_size_not_null
      when 'new_nok'
        active_scaffold_config.label = "Newly Registered Companies with Missing Documentation"
        super.with_state(:registered).stamp_file_size_or_license_file_size_or_logo_file_size_null
      when 'approved'
        active_scaffold_config.label = "Approved Companies"
        super.with_state(:approved)
      when 'expired'
        active_scaffold_config.label = 'Expired Companies'
        super.with_state(:expired)
      when "expiring"
        active_scaffold_config.label = 'Companies Expiring within 7 Days'
        super.with_state(:approved).expires_at_greater_than(Time.now).expires_at_less_than(Time.now + 1.week)
      when "lic_expired"
        active_scaffold_config.label = 'Companies with an Expired Trade License'
        super.with_state(:approved).license_expires_at_less_than(Time.now)
      when "lic_expiring"
        active_scaffold_config.label = 'Companies with an Expiring Trade License within 7 Days'
        super.with_state(:approved).license_expires_at_greater_than(Time.now).license_expires_at_less_than(Time.now + 1.week)
      when "trained"
        active_scaffold_config.label = 'Trained Companies'
        super.with_state(:approved).where("trained_at IS NOT NULL")
      when "untrained"
        active_scaffold_config.label = 'Un-Trained Companies'
        super.with_state(:approved).where("trained_at IS NULL")
      else
        active_scaffold_config.label = 'All Companies'
        super
    end
  end
end
scambra commented 12 years ago

Try changing :inline => false with page => true (and inline = false with page = true of course)

khelal commented 12 years ago

Yes! That worked!

khelal commented 12 years ago

Just found out that the same problem exists on the search functionality. After entering a search term and clicking on the Search button, nothing happens. After refreshing the page, the right results are displayed.