Toggle Search

25 views
Skip to first unread message

jhe...@gmail.com

unread,
Dec 3, 2020, 9:48:53 AM12/3/20
to ActiveScaffold : Ruby on Rails Gem

Hi

Is it possible to add an action/button/whatever to let my users toggle between seach and field search in an List?

Regards, Jan

Sergio Cambra

unread,
Dec 4, 2020, 5:28:28 AM12/4/20
to ActiveScaffold : Ruby on Rails Gem
Hi

By default, you must choose if you want to use search or field search actions,
swapping search with field_search action (config.actions.swap :search,
:field_search), or leaving default search action.

If you add field_search action, instead of swapping search, it will add
action_link to show search with same parameters as search's action link, which
will open form for search action. You can define kind parameter of the
field_search's action_link:

config.field_search.link.parameters = {:kind => :field_search}

In this way, you will get 2 show search links, so you may want to change some
labels too.

Regards


jhe...@gmail.com

unread,
Dec 10, 2020, 11:37:41 AM12/10/20
to ActiveScaffold : Ruby on Rails Gem
Hi

This works like a charm, thanky you very much.

Regards, Jan

Dennis Bulgatz

unread,
Feb 21, 2021, 12:14:53 AM2/21/21
to ActiveScaffold : Ruby on Rails Gem
Can you confirm that search/field_search swap is working in current master, or 3.6.0 rc2 ?  I can only get search or field search to work, not both, and no "swap" behavior.

If you have a working controller example, could you post it?

Thanks!

Sergio Cambra

unread,
Feb 22, 2021, 5:34:27 AM2/22/21
to ActiveScaffold : Ruby on Rails Gem, Dennis Bulgatz

Hi


This is how I did in the past, it's in a project I haven't upgraded to master yet, but I think it should still work:



   config.actions << :field_search


   config.field_search.link.parameters = {:kind => :field_search}

Regards

Dennis Bulgatz

unread,
Feb 22, 2021, 11:55:28 PM2/22/21
to ActiveScaffold : Ruby on Rails Gem
Hi Sergio,

Thanks, but this is not working for me.  I can get only field_search or search to work, but not both, using separate links, or the swap.  I decided I would try to build a fresh application, so there would be no ambiguity about the test case, and thought it would also be good to document this somewhere.  I was able to get the application to build, but not function properly.  I think you need to update the bundle exec rails g active_scaffold:install to work with latest rails stack, which has rearranged the asset folder.  Here are the steps I followed to build the test application on my mac.

Rails6 ActiveScaffoldProjectSetup

git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch --unshallow
brew update
brew install node
brew install yarn

brew install rbenv
rbenv install 2.7.1
gem install bundler
 Successfully installed bundler-2.2.11
gem install rails -v 6.0.3.5


# Installing mysql2 gem with macOS Mojave and Brew
gem install mysql2  -v '0.5.3' -- \
--with-mysql-config /usr/local/Cellar/mysql@5.7/5.7.29/bin/mysql_config \
--with-cppflags=-I/usr/local/opt/openssl@1.1/include \
--with-ldflags=-L/usr/local/opt/openssl@1.1/lib


 mkdir rails6app
 cd rails6app/

#bundler using old version
gem update --system

#create the new Rails app
rails _6.0.3.5_ new myapp -d mysql

cd myapp

#Add to Gemfile
gem 'active_scaffold', '3.6.0.rc2'
gem 'jquery-rails'
gem 'jquery' #Used by active_scaffold

#run Bundle install
bundle install

#create  app/assets/javascripts/application.js, and add these lines
#The new architecture has moved the javascript folder and renamed it!
//= require jquery
//= require jquery_ujs
//= require_tree .
//= require active_scaffold


#Setup your rails app for Active Scaffold
bundle exec rails g active_scaffold:install 

#Create the database
bundle exec rails db:create

#Create a resource
rails g active_scaffold:resource vehicle m_id:integer chassis:string type:string yr_made:string yr_ended:string doors:string drive_train:string e_mnt:string hp:integer trq:integer e_id:integer trans:string

#Run the migration created to build the new resource
bundle exec rails db:migrate

#start the app
bundle exec rails s

#navigate to Resource

Sergio Cambra

unread,
Feb 23, 2021, 7:40:49 AM2/23/21
to ActiveScaffold : Ruby on Rails Gem, Dennis Bulgatz
Hi Dennis

Yes, you are right about rails 6, that's why I haven't released 3.6.0 yet. I
started to work on supporting webpack, but finally I decided I will postpone
webpack support to later version. But generator needs to work with 3.6.0,
setting up javascript pipeline, then I will release 3.6.0.

About this issue, I have done that, but I think you may forget some steps,
maybe you did them but you didn't put them in the email:

Add this to layouts/application.html.erb:
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>

Add application.js to precompile in config/initializers/assets.rb:
Rails.application.config.assets.precompile += %w( application.js )

Without those steps, links are not working, although I can see 2 search action
links if I add these lines to controller:
conf.actions << :field_search
conf.field_search.link.parameters = {:kind => :field_search}

Once I add javascript_include_tag and application.js to assets precompile, I
can get action links working, including both search action links.

It may be useful to change label for one search action link, for example:
conf.field_search.link.label = 'Field Search'

Also, I don't know what gem is "jquery", but you don't need it, jquery-rails
gem has jquery.js and jquery_ujs.js, although I think it should work with
jquery-rails gem and rails-ujs.js instead of jquery_ujs.js

And I think it could work if you add only jquery and active_scaffold to app/
assets/javascripts/application.js, and leave javascript_pack_tag in your
layout, which should already include rails-ujs and turbolinks.

Regards

El martes, 23 de febrero de 2021 5:55:27 (CET) Dennis Bulgatz escribió:
> Hi Sergio,
>
> Thanks, but this is not working for me. I can get only field_search or
> search to work, but not both, using separate links, or the swap. I decided
> I would try to build a fresh application, so there would be no ambiguity
> about the test case, and thought it would also be good to document this
> somewhere. I was able to get the application to build, but not function
> properly. I think you need to update the bundle exec *rails g
> active_scaffold:install to work with latest rails stack, which has
> rearranged the asset folder. *Here are the steps I followed to build the
> test application on my mac.
>
> *Rails6 ActiveScaffoldProjectSetup*
>
> *git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask fetch
> --unshallow*
> *brew update*
> *brew install node*
> *brew install yarn*
>
> *brew install rbenv*
> *rbenv install 2.7.1*
> *gem install bundler*
> * Successfully installed bundler-2.2.11*
> *gem install rails -v 6.0.3.5*
>
>
> *# Installing mysql2 gem with macOS Mojave and Brew*
> *gem install mysql2 -v '0.5.3' -- \*
> *--with-mysql-config /usr/local/Cellar/mysql@5.7/5.7.29/bin/mysql_config \*
> *--with-cppflags=-I/usr/local/opt/openssl@1.1/include \*
> *--with-ldflags=-L/usr/local/opt/openssl@1.1/lib*
>
>
> * mkdir rails6app*
> * cd rails6app/*
>
> *#bundler using old version*
> *gem update --system*
>
> *#create the new Rails app*
> *rails _6.0.3.5_ new myapp -d mysql*
>
> *cd myapp*
>
> *#Add to Gemfile*
> *gem 'active_scaffold', '3.6.0.rc2'*
> *gem 'jquery-rails'*
> *gem 'jquery' #Used by active_scaffold*
>
> *#run Bundle install*
> *bundle install*
>
> *#create app/assets/javascripts/application.js, and add these lines*
> *#The new architecture has moved the javascript folder and renamed it!*
> *//= require jquery*
> *//= require jquery_ujs*
> *//= require_tree .*
> *//= require active_scaffold*
>
>
> *#Setup your rails app for Active Scaffold*
> *bundle exec rails g active_scaffold:install *
>
> *#Create the database*
> *bundle exec rails db:create*
>
> *#Create a resource*
> *rails g active_scaffold:resource vehicle m_id:integer chassis:string
> type:string yr_made:string yr_ended:string doors:string drive_train:string
> e_mnt:string hp:integer trq:integer e_id:integer trans:string*
>
> *#Run the migration created to build the new resource*
> *bundle exec rails db:migrate*
>
> *#start the app*
> *bundle exec rails s*
>
> *#navigate to Resource*
> *http://localhost:3000/vehicles*

Dennis Bulgatz

unread,
Feb 23, 2021, 9:47:27 AM2/23/21
to ActiveScaffold : Ruby on Rails Gem
Sergio,

Thanks so much.  All is working with my test app.

Can I help you to better document ActiveScaffold?  It is a great tool, but as complex as it is, needs many of the the examples from this google group to be organized into the API docs.

Thanks again for all you do!

Sergio Cambra

unread,
Feb 23, 2021, 10:11:25 AM2/23/21
to ActiveScaffold : Ruby on Rails Gem, Dennis Bulgatz
Dennis

That would be great, every help is needed. My long term plans are move API doc
from wiki to rdoc, which means adding rdoc comments to methods, at least for
files in config and data_structures directories. And also in some methods of
actions and helper modules, explaining methods which may be overrided in app
controller or helper.

Of course, it would be great if some examples with tips and explanations can
be added to wiki.

Regards

Dennis Bulgatz

unread,
Feb 23, 2021, 12:35:01 PM2/23/21
to ActiveScaffold : Ruby on Rails Gem
HI Sergio,

I will work on the wiki pages to add some examples and maybe the Mac setup for Active scaffold in this thread.  I have authored more than a few sites using AS, so have a lot of examples.

Sergio Cambra

unread,
Feb 24, 2021, 8:04:02 AM2/24/21
to ActiveScaffold : Ruby on Rails Gem
Hi Dennis

Thanks for your contribution, it's really helpful.

Regards

Dennis Bulgatz

unread,
Feb 26, 2021, 11:12:38 AM2/26/21
to ActiveScaffold : Ruby on Rails Gem
Glad to help.  Not sure if you want to change anything about how the wiki pages are structured?  I develop on a mac, but the applications run under RHEL.  Is windows the most common dev env?  If so, be great if someone that is a windows users wrote a similar guide.  One of my colleagues used the linux subsystem with windows for dev, no idea how common this is.  Ran pretty slow.

Sergio Cambra

unread,
Feb 26, 2021, 4:00:52 PM2/26/21
to ActiveScaffold : Ruby on Rails Gem
I only knew one person who tried to develop with ruby in Windows and found many issues, finally he changed to Linux, I think it's possible, but I don't think is very common, although it was years ago, maybe it's easier now.

--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails Gem" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activescaffol...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/activescaffold/3b715a26-04c5-4efd-884a-7289570c86ben%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages