Rails 4 Modifying Scaffold Output. Removing Test files - ruby-on-rails-4

I am attempting to follow the guide http://guides.rubyonrails.org/generators.html. In section 5 Customizing Your Workflow, it discusses modifying this code within config/application.rb:
config.generators do |g|
g.orm :active_record
g.template_engine :erb
g.test_framework :test_unit, fixture: true
end
However, when I open this file, I do not see these lines!
My ruby version is 1.9.3p327, and my rails version is 4.0.0
Are these lines located in another file? Did I generate my application incorrectly?

That used to be commented out by default in Rails 3, it was removed altogether in Rails 4. I think you should be okay if you just add it in manually.
Ryan has a few words about that here: http://asciicasts.com/episodes/216-generators-in-rails-3

Related

sprockets - precompiling a standalone asset

I am trying to make sprokets compile a single standalone js asset, so it will uglify and minify it and be part of the entire rails projects.
I need that this js to have a non-digest name, so it's will not change (i.e. embedded in other websites, etc)
I can't seem to force rails (4) /sprockets to do my bidding.
What I tried:
Adding the asset (script.js) in a misc folder unders assets/javascripts and not load it in the sprockets javascript manifest. While this keeps it in the project, it doesn't get uglified and minified, and doesn't get automatically loaded via asset-sync.
Tried adding another manifest called scripts-manifest.js to //= require script.js asset, to add its path in the precompile path in application.rb, but the problem is that rails 4 adds digest to all assets no matter what (doesn't work like that in rails 3)
Tried using https://github.com/alexspeller/non-stupid-digest-assets to add a non digest version of the asset. I may have done it incorrectly, as it doesn't work or do anything..
I add the initializer NonStupidDigestAssets.whitelist = ["script.js"] and tried putting it in app/assets/javascripts/misc and in public/ but it still won't work/
I have read that this gem should help in most cases, and I am sure I am doing something wrong with either path definition or no including it somewhere
One way to do this is to add an initializer that generates the compiled versions directly.
Add your js file to a subfolder in /app/assets/javascripts. Don't include this in application.js so it isn't added to the compiled assets.
Create an initializer in /config/initializers that uses uglify directly
output_file = "#{Rails.root}/public/public_script.js"
input_file = "#{Rails.root}/app/assets/javascripts/non_digest/public_script.js"
uglified = Uglifier.compile(File.read(input_file))
File.open(output_file, 'w') {|f| f.write(uglified) }
Include the public js file (in this example: /public/public_script.js) in your application layout
This way you have direct access to make custom changes to how uglify handles your js and the location of the file never changes for your external services accessing them.
I did all this locally and tested that it worked using the beta version of Rails 4.2
Just wanted to add my own solution based off Ken's answer.
I created non_digest.rb in config/initializers:
Dir["#{Rails.root}/app/assets/javascripts/non_digest/*"].each do |asset|
asset_name = File.basename(asset)
asset_output = "#{Rails.root}/public/external/#{asset_name}"
asset_uglified = Uglifier.compile(File.read(asset))
File.open(asset_output, 'w') {|a| a.write(asset_uglified) }
end
Don't forget to stub the file in javascripts/application.js. as we probably don't want it compiled with the rest of our JS and we can continue to use //= require_tree .:
//= stub non_digest/external_bookmarklet
the way you would do this with rails 4 is the following:
add it to the precompile list config.assets.precompile += %w(your_file_name.js)
make sure it's not referenced in application.js (directly or via require_tree)
symlink the digested file on deployment
read the manifest.yml to get the actual filename
ln -s digested-filename.js actual-filename.js
since rails 4, generation of non-digested assets has been removed (for good reasons) and this is a simple and straight forward way to implement the desired behavior.

The gem simple_form displays numbers instead of associated stings, when using the enums introduced in Rails 4.1

Rails 4.1 introduced enum, which don't play well with the latest version of simple_form. When used with associations, simple_form displays numbers instead of the associated stings. Any solutions or work arounds?
Add the following lines to your Gemfile
# Help ActiveRecord::Enum feature to work fine with I18n and simple_form.
gem 'enum_help'
Learn more here

Vtiger 6 - customize login page

Where is the login page for VTIGER 6?
I tried /Smarty/templates.
However, the login.tpl there is the old Vtiger 5.4.
I want to customize the login page.
Thanks.
To customize login page, just go to folder: vtigercrm\layouts\vlayout\modules\Users
Duplicate file: Login.Default.tpl rename to Login.Custom.tpl
You can modify it safely there
In case, you need some new images or modify them, you can go to folder: vtigercrm\layouts\vlayout\skins\images
Full customization for vTiger 6 can be done via the following files:
layouts\vlayout\modules\Users\login.tpl
layouts\vlayout\modules\Vtiger\header.tpl
layouts\vlayout\skins\softed\style.css
Its in layouts/vlayout/modules/Users/login.tpl
I doubt you are using Vtiger EA version. Use the stable version always
in Vtiger version 6 the folder structure is changed a bit.
In new version they have moved it under layouts folder.
To modify you can edit the file layouts/vlayout/modules/Users/Login.tpl
Fore more details on new file/folder structure please check https://wiki.vtiger.com/index.php/Vtiger_6_Developer_Guide#Folder_Structure
Thank You
In case of vTigerCRM 6.0 use the following file to change the login screen
layouts/vlayout/modules/Users/login.tpl
And for vTigerCRM 6.2 onwards change the following file
layouts/vlayout/modules/Users/Login.Custom.tpl
Here login.tpl checks whether the developer has the Login.Custom.tpl or not (Please check the attached screenshot). Else it loads the Login.Default.tpl

How to get osCommerce 2.2 running on PHP 5.4?

I recently upgraded PHP to 5.4 and after adding some tweaks now the old osCommerce installation of a customer with lots of customisations is running again, but there is still a problem:
if you put an item in your cart the cart stays empty
How can I fix this?
Is there a certain php value I can set in php.ini so the session is working properly?
What I have tweaked so far:
Problem: all prices are 0 and there is no currency
Solution: adding !isset($currency) || in the paragraph `//
(see $currency not set in application_top under PHP 5.4 )
Problem: register_globals is REMOVED as of PHP 5.4.0
Solution: I simulated register_globals with this: https://serverfault.com/a/547285/128892
and I added this to includes/application_top.php:
// Bugfix PHP 5.4:
$HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"];
$HTTP_ACCEPT_LANGUAGE=$_SERVER["HTTP_ACCEPT_LANGUAGE"];
$HTTP_HOST=$_SERVER["HTTP_HOST"];
$SERVER_NAME=$_SERVER["SERVER_NAME"];
$PHP_SELF=$_SERVER['PHP_SELF'];
$HTTP_GET_VARS=$_GET;
$HTTP_POST_VARS=$_POST;
register_globals();
comment out this line:
#ini_get('register_globals') or exit('FATAL ERROR: register_globals is disabled in php.ini, please enable it!');
also I had to correct some removed functions in includes/functions/sessions.php: session_unregister() and session_is_registered()
Problem remaining:
Items filled into the cart don't get added to the cart. seems like the session isn't known in the add_cart page.
I've had the same problem. Found by comparing my 2.2ms2 code with rc2a version.
In application_top change
$cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$quantity, $_POST['id']);
to
$cart->add_cart($_POST['products_id'], $cart->get_quantity(tep_get_uprid($_POST['products_id'], $_POST['id']))+$_POST['quantity'], $_POST['id']);
I cound not fix this last problem, so after trying diffenent attempts I decided to take the effort and convert the shop with all its customisations into oscommerce 2.3 which still runs on PHP 5.4 (up to PHP 5.6).
Note that later, to get oscommerce running on php7 you'll need another fix for mysql functions to fix problems like Undefined function mysql_connect()

Theming sencha touch list

I want to change the color of the headers in a grouped list. For the moment I've got the default theme. I think I have to use something like "$list-header-bg-color" but :
WHERE can I use it ? I tried to write something like :
$list-header-bg-color = '#CCC'
directly at the end of the "sencha-touch.css" file but it doesn't work at all ... Somebody can explain me how does it works ? (with a little example please). Thanks in advance
First you need to install ruby
then install ruby gems
then install compass
then open your application *.scss file (should be in resources/sass/)
after the line
#import 'sencha-touch/default/all';
include your line
$list-header-bg-color = '#CCC'
Note that by default the value of this var is
$list-header-bg-color: transparentize(saturate($base-color, 10%), .25);
Maybe you can change the base-color to have a more "unified" look (depending on what you want to do ...)
then compile your scss file
compass compile
Now your theme should have been compiled to your app.css and your new color is good :)
For more detail check this article I wrote not long ago : sass-for-sencha-touch-2-windows-7
Sencha is using SASS for theming. So that line should go in the sencha-touch.scss file. Then you should compile that file with compass to get a css file. See this videos:
http://vimeo.com/26506883
http://vimeo.com/17879651
slides from presentation http://www.slideshare.net/senchainc/theming-sencha-touch
reference docs http://dev.sencha.com/deploy/touch/docs/theme/
Check this also http://www.sencha.com/blog/sencha-touch-theme-contest-winners-announced/