I am using rails 3 activesacaffold plugin for my admin pannel. I have a table which has big int values.
When I list the values its showing as '62,175,049,070'. How can I format this to show like '62175049070'. Since we are using activescaffold plugin we dont have any direct view pages to make modification.
Please help!
Use the delimiter option:
active scaffold :model do
...
conf.columns[:ndc].options = {:i18n_number => {:delimiter => ''}}
...
end
https://github.com/activescaffold/active_scaffold/wiki/API:-Column
Related
I have got a Yii 1.0 project and I am trying to insert a form data using its model. Is there any configuration I need to do to escape quotes in my query?
It may help you. I also face this earlier this is due to breaking of query then i used param method to pass variables
Model::model()->update(array('status' => 1), 'username=:username', array(':username' => $model->username));
I have a very simple piece of code :
$dropOrder = new DropOrder($dropOrderId);
$dropOrder->is_supplier_paid = $payValue;
$dropOrder->save();
It works and saves a 'is_supplier_paid' field value into the database. But it also does unexpected actions and fills all null valued fields with 0 values.
I try to save it like this :
$dropOrder->save(true);
But I still have the same strange behavior. I want to change one field only and don't touch the other ones.
Values are formated by ObjectModel::formatValue() before they are inserted / updated, based on the type of the field declared in your $definition.
You have to use TYPE_NOTHING to allow NULL values, it's the only way.
Take a look in Configuration class, with id_shop and id_group_shop fields.
PrestaShop 1.7:
I ran into the same problem in PS 1.7 and set TYPE_NOTHING is not sufficient to resolve this issue. In my case i also needed to add allow_null to true in the field's definition:
'my_field' => ['type' => self::TYPE_NOTHING, 'allow_null' => true, 'value' => null]
('value' => null is probably not necessary but suggested)
Respected ppl ...
I have a grave design issue since many days ...kindly help out ...
Im coming to this stage from the previous screen after entering the hospital_id which u can c from the URL is 10 (using ransack) ... at this stage when i click "Add performance detail for employee" im passing only the employee_id to the performance creation screen ...
How do i capture the hospital_id from the previous screen and store in my performance creation screen ? ... (it has field hospital_id) ....
can i somehow use this raw sql query to store hospital_id directly ? ...
SELECT hospital_id
FROM employee_sanction_working
WHERE employee_id
Pls do help ...
Thnx
There are few ways you can resolve your problem:
1) you can pass hospital_id in parameter as Rubyman and Santhosh K have suggested Or
2) you can create a class variable in controller which you can use in your erb or haml view.
for example:
in controller:
def new
#hospital_id = params[:hospital_id] #this you can use in your view
end
in view
Hospital ID is <%= #hospital_id %>
Please refer this for more information
You can pass the hospital_id as parameter to "Add performance detail for employee" link.
I'm trying to use number_to_currency to get two digits after the decimal dot in Rails 3, but I can get only one. My DB field is defined like this:
t.decimal "amount", :precision => 5, :scale => 2
In my template I have:
#{number_to_currency(#purch.amount)}
And yet as the result I get: PLN 34,7
In the DB I can clearly see: 34.70
I would like to see my second zero - is it a feature or am I missing something?
Thanks!
The answer is to check the following setting in one's locale configuration file:
currency:
format:
strip_insignificant_zeros: false
Since you seem to be using a custom locale, try forcing the behavior you want by explicitly setting the options of number_to_currency:
number_to_currency(#purch.amount, :precision => 2)
You can also set these options in the locale file for your language. Take a look at http://guides.rubyonrails.org/i18n.html
I am sending an array from jquery via the url requerts to the rails controller.
when I do this in my controller
log_array = (params[:log_ids])
logger.debug "This is the array #{log_array.to_a}"
I get this in my server log
This is the array 85,84,83,82
I am trying this query to get all the selected logs:
#logs = Log.where(['"logs"."id" IN (?)', log_array])
I get this on the server log
SELECT "logs".* FROM "logs" WHERE ("logs"."id" IN ('85,84,83,82'))
It sould be like this
SELECT "logs".* FROM "logs" WHERE ("logs"."id" IN (85,84,83,82))
It seems like it puts the arry in like a string.
Is there any way to make the sql right for an array?
You're making things too SQL-ish. Try this:
Log.find_all(params[:log_ids])
Or Log.where(:id => params[:log_ids]) if you want to use where() goodness.
Would use the .where listed below...check out the link to the rails 3.1 deprecations.
http://m.onkey.org/active-record-query-interface