Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
likvid
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Cederqvist
likvid
Commits
b4d7910e
Commit
b4d7910e
authored
18 years ago
by
Per Cederqvist
Browse files
Options
Downloads
Patches
Plain Diff
Added the /saldos/new_snapshot method, to allow easy entry of all saldos.
parent
5a67fbed
No related branches found
No related tags found
Loading
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/controllers/saldos_controller.rb
+29
-0
29 additions, 0 deletions
app/controllers/saldos_controller.rb
app/views/layouts/application.rhtml
+1
-0
1 addition, 0 deletions
app/views/layouts/application.rhtml
app/views/saldos/new_snapshot.rhtml
+14
-0
14 additions, 0 deletions
app/views/saldos/new_snapshot.rhtml
with
44 additions
and
0 deletions
app/controllers/saldos_controller.rb
+
29
−
0
View file @
b4d7910e
...
@@ -48,4 +48,33 @@ class SaldosController < ApplicationController
...
@@ -48,4 +48,33 @@ class SaldosController < ApplicationController
Saldo
.
find
(
params
[
:id
]).
destroy
Saldo
.
find
(
params
[
:id
]).
destroy
redirect_to
:action
=>
'list'
redirect_to
:action
=>
'list'
end
end
def
new_snapshot
@saldos
=
[]
for
account
in
Account
.
find_all
@saldos
<<
Saldo
.
new
(
:account_id
=>
account
.
id
,
:date
=>
Date
.
today
)
end
end
def
create_snapshot
ok
=
true
@saldos
=
[]
(
0
...
params
[
:saldos
].
to_i
).
each
{
|
ix
|
saldo
=
Saldo
.
new
(
params
[
:saldo
][
ix
.
to_s
])
puts
ix
puts
params
[
:saldo
][
ix
]
puts
params
[
:saldo
]
if
not
saldo
.
save
ok
=
false
end
@saldos
<<
saldo
}
if
ok
flash
[
:notice
]
=
'Saldos were successfully created.'
redirect_to
:action
=>
'list'
else
render
:action
=>
'new_snapshot'
end
end
end
end
This diff is collapsed.
Click to expand it.
app/views/layouts/application.rhtml
+
1
−
0
View file @
b4d7910e
...
@@ -21,5 +21,6 @@
...
@@ -21,5 +21,6 @@
<br
/>
<br
/>
<%=
link_to
'Top'
,
:controller
=>
"/"
%>
<%=
link_to
'Top'
,
:controller
=>
"/"
%>
<%=
link_to
'New saldos'
,
:controller
=>
"saldos"
,
:action
=>
"new_snapshot"
%>
</body>
</body>
</html>
</html>
This diff is collapsed.
Click to expand it.
app/views/saldos/new_snapshot.rhtml
0 → 100644
+
14
−
0
View file @
b4d7910e
<%
@heading
=
@saldos
[
0
][
"date"
].
strftime
(
"Saldos per %Y-%m-%d"
)
%>
<%=
start_form_tag
:action
=>
'create_snapshot'
%>
<input
type=
"hidden"
name=
"saldos"
value=
"
<%=
@saldos
.
length
%>
"
/>
<%
@saldos
.
each_index
{
|
ix
|
saldo
=
@saldos
[
ix
]
%>
<p><label
for=
"saldo_account_id"
>
<%=
saldo
.
account
.
name
%>
</label><br
/>
<input
type=
"text"
name=
"saldo[
<%=
ix
%>
][amount]"
value=
"
<%=
saldo
.
amount
%>
"
/>
<input
type=
"hidden"
name=
"saldo[
<%=
ix
%>
][date]"
value=
"
<%=
saldo
.
date
%>
"
/>
<input
type=
"hidden"
name=
"saldo[
<%=
ix
%>
][account_id]"
value=
"
<%=
saldo
.
account
.
id
%>
"
/>
</p>
<%
}
%>
<%=
submit_tag
"Create"
%>
<%=
end_form_tag
%>
<%=
link_to
'Back'
,
:action
=>
'list'
%>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment